[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/externals/diff_match_patch/ -> diff_match_patch.php (summary)

Diff Match and Patch Copyright 2006 Google Inc. http://code.google.com/p/google-diff-match-patch/

File Size: 2117 lines (71 kb)
Included or required:0 times
Referenced: 1 time
Includes or requires: 0 files

Defines 2 classes

diff_match_patch:: (36 methods):
  diff_main()
  diff_compute()
  diff_linesToChars()
  diff_linesToCharsMunge()
  diff_charsToLines()
  diff_map()
  diff_path1()
  diff_path2()
  diff_commonPrefix()
  diff_commonSuffix()
  diff_halfMatch()
  diff_halfMatchI()
  diff_cleanupSemantic()
  diff_cleanupSemanticLossless()
  diff_cleanupSemanticScore()
  diff_cleanupEfficiency()
  diff_cleanupMerge()
  diff_xIndex()
  diff_prettyHtml()
  diff_text1()
  diff_text2()
  diff_levenshtein()
  diff_toDelta()
  diff_fromDelta()
  match_main()
  match_bitap()
  match_bitapScore()
  match_alphabet()
  patch_addContext()
  patch_make()
  patch_deepCopy()
  patch_apply()
  patch_addPadding()
  patch_splitMax()
  patch_toText()
  patch_fromText()

patch_obj:: (8 methods):
  toString()
  __toString()
  charCodeAt()
  mb_ord()
  mb_chr()
  encodeURI()
  decodeURI()
  echo_Exception()


Class: diff_match_patch  - X-Ref

Class containing the diff, match and patch methods.

diff_main($text1, $text2, $checklines = true)   X-Ref
Find the differences between two texts.  Simplifies the problem by stripping
any common prefix or suffix off the texts before diffing.

param: {string} text1 Old string to be diffed.
param: {string} text2 New string to be diffed.
param: {boolean} opt_checklines Optional speedup flag.  If present and false,
return: {Array.<Array.<number|string>>} Array of diff tuples.

diff_compute($text1, $text2, $checklines)   X-Ref
Find the differences between two texts.  Assumes that the texts do not
have any common prefix or suffix.

param: {string} text1 Old string to be diffed.
param: {string} text2 New string to be diffed.
param: {boolean} checklines Speedup flag.  If false, then don't run a
return: {Array.<Array.<number|string>>} Array of diff tuples.

diff_linesToChars($text1, $text2)   X-Ref
Split two texts into an array of strings.  Reduce the texts to a string of
hashes where each Unicode character represents one line.

param: {string} text1 First string.
param: {string} text2 Second string.
return: {Array.<string|Array.<string>>} Three element Array, containing the

diff_linesToCharsMunge($text, &$lineArray, &$lineHash)   X-Ref
Split a text into an array of strings.  Reduce the texts to a string of
hashes where each Unicode character represents one line.
Modifies linearray and linehash through being a closure.

param: {string} text String to encode
return: {string} Encoded string

diff_charsToLines(&$diffs, $lineArray)   X-Ref
Rehydrate the text in a diff from a string of line hashes to real lines of
text.

param: {Array.<Array.<number|string>>} diffs Array of diff tuples.
param: {Array.<string>} lineArray Array of unique strings.

diff_map($text1, $text2)   X-Ref
Explore the intersection points between the two texts.

param: {string} text1 Old string to be diffed.
param: {string} text2 New string to be diffed.
return: {Array.<Array.<number|string>>?} Array of diff tuples or null if no

diff_path1($v_map, $text1, $text2)   X-Ref
Work from the middle back to the start to determine the path.

param: {Array.<Object>} v_map Array of paths.ers
param: {string} text1 Old string fragment to be diffed.
param: {string} text2 New string fragment to be diffed.
return: {Array.<Array.<number|string>>} Array of diff tuples.

diff_path2($v_map, $text1, $text2)   X-Ref
Work from the middle back to the end to determine the path.

param: {Array.<Object>} v_map Array of paths.
param: {string} text1 Old string fragment to be diffed.
param: {string} text2 New string fragment to be diffed.
return: {Array.<Array.<number|string>>} Array of diff tuples.

diff_commonPrefix($text1, $text2)   X-Ref
Determine the common prefix of two strings

param: {string} text1 First string.
param: {string} text2 Second string.
return: {number} The number of characters common to the start of each

diff_commonSuffix($text1, $text2)   X-Ref
Determine the common suffix of two strings

param: {string} text1 First string.
param: {string} text2 Second string.
return: {number} The number of characters common to the end of each string.

diff_halfMatch($text1, $text2)   X-Ref
Do the two texts share a mb_substring which is at least half the length of the
longer text?

param: {string} text1 First string.
param: {string} text2 Second string.
return: {Array.<string>?} Five element Array, containing the prefix of

diff_halfMatchI($longtext, $shorttext, $i)   X-Ref
Does a mb_substring of shorttext exist within longtext such that the mb_substring
is at least half the length of longtext?
Closure, but does not reference any external variables.

param: {string} longtext Longer string.
param: {string} shorttext Shorter string.
param: {number} i Start index of quarter length mb_substring within longtext
return: {Array.<string>?} Five element Array, containing the prefix of

diff_cleanupSemantic(&$diffs)   X-Ref
Reduce the number of edits by eliminating semantically trivial equalities.

param: {Array.<Array.<number|string>>} diffs Array of diff tuples.

diff_cleanupSemanticLossless(&$diffs)   X-Ref
Look for single edits surrounded on both sides by equalities
which can be shifted sideways to align the edit to a word boundary.
e.g: The c<ins>at c</ins>ame. -> The <ins>cat </ins>came.

param: {Array.<Array.<number|string>>} diffs Array of diff tuples.

diff_cleanupSemanticScore($one, $two)   X-Ref
Given two strings, compute a score representing whether the internal
boundary falls on logical boundaries.
Scores range from 5 (best) to 0 (worst).
Closure, makes reference to regex patterns defined above.

param: {string} one First string
param: {string} two Second string
return: {number} The score.

diff_cleanupEfficiency(&$diffs)   X-Ref
Reduce the number of edits by eliminating operationally trivial equalities.

param: {Array.<Array.<number|string>>} diffs Array of diff tuples.

diff_cleanupMerge(&$diffs)   X-Ref
Reorder and merge like edit sections.  Merge equalities.
Any edit section can move as long as it doesn't cross an equality.

param: {Array.<Array.<number|string>>} diffs Array of diff tuples.

diff_xIndex($diffs, $loc)   X-Ref
loc is a location in text1, compute and return the equivalent location in
text2.
e.g. 'The cat' vs 'The big cat', 1->1, 5->8

param: {Array.<Array.<number|string>>} diffs Array of diff tuples.
param: {number} loc Location within text1.
return: {number} Location within text2.

diff_prettyHtml($diffs)   X-Ref
Convert a diff array into a pretty HTML report.

param: {Array.<Array.<number|string>>} diffs Array of diff tuples.
return: {string} HTML representation.

diff_text1($diffs)   X-Ref
Compute and return the source text (all equalities and deletions).

param: {Array.<Array.<number|string>>} diffs Array of diff tuples.
return: {string} Source text.

diff_text2($diffs)   X-Ref
Compute and return the destination text (all equalities and insertions).

param: {Array.<Array.<number|string>>} diffs Array of diff tuples.
return: {string} Destination text.

diff_levenshtein($diffs)   X-Ref
Compute the Levenshtein distance; the number of inserted, deleted or
substituted characters.

param: {Array.<Array.<number|string>>} diffs Array of diff tuples.
return: {number} Number of changes.

diff_toDelta($diffs)   X-Ref
Crush the diff into an encoded string which describes the operations
required to transform text1 into text2.
E.g. =3\t-2\t+ing  -> Keep 3 chars, delete 2 chars, insert 'ing'.
Operations are tab-separated.  Inserted text is escaped using %xx notation.

param: {Array.<Array.<number|string>>} diffs Array of diff tuples.
return: {string} Delta text.

diff_fromDelta($text1, $delta)   X-Ref
Given the original text1, and an encoded string which describes the
operations required to transform text1 into text2, compute the full diff.

param: {string} text1 Source string for the diff.
param: {string} delta Delta text.
return: {Array.<Array.<number|string>>} Array of diff tuples.

match_main($text, $pattern, $loc)   X-Ref
Locate the best instance of 'pattern' in 'text' near 'loc'.

param: {string} text The text to search.
param: {string} pattern The pattern to search for.
param: {number} loc The location to search around.
return: {number} Best match index or -1.

match_bitap($text, $pattern, $loc)   X-Ref
Locate the best instance of 'pattern' in 'text' near 'loc' using the
Bitap algorithm.

param: {string} text The text to search.
param: {string} pattern The pattern to search for.
param: {number} loc The location to search around.
return: {number} Best match index or -1.

match_bitapScore($e, $x, $pattern, $loc)   X-Ref
Compute and return the score for a match with e errors and x location.
Accesses loc and pattern through being a closure.

param: {number} e Number of errors in match.
param: {number} x Location of match.
return: {number} Overall score for match (0.0 = good, 1.0 = bad).

match_alphabet($pattern)   X-Ref
Initialise the alphabet for the Bitap algorithm.

param: {string} pattern The text to encode.
return: {Object} Hash of character locations.

patch_addContext($patch, $text)   X-Ref
Increase the context until it is unique,
but don't let the pattern expand beyond Match_MaxBits.

param: {patch_obj} patch The patch to grow.
param: {string} text Source text.

patch_make($a, $opt_b = null, $opt_c = null )   X-Ref
Compute a list of patches to turn text1 into text2.
Use diffs if provided, otherwise compute it ourselves.
There are four ways to call this function, depending on what data is
available to the caller:
Method 1:
a = text1, b = text2
Method 2:
a = diffs
Method 3 (optimal):
a = text1, b = diffs
Method 4 (deprecated, use method 3):
a = text1, b = text2, c = diffs

param: {string|Array.<Array.<number|string>>} a text1 (methods 1,3,4) or
param: {string|Array.<Array.<number|string>>} opt_b text2 (methods 1,4) or
param: {string|Array.<Array.<number|string>>} opt_c Array of diff tuples for
return: {Array.<patch_obj>} Array of patch objects.

patch_deepCopy($patches)   X-Ref
Given an array of patches, return another array that is identical.

param: {Array.<patch_obj>} patches Array of patch objects.
return: {Array.<patch_obj>} Array of patch objects.

patch_apply($patches, $text)   X-Ref
Merge a set of patches onto the text.  Return a patched text, as well
as a list of true/false values indicating which patches were applied.

param: {Array.<patch_obj>} patches Array of patch objects.
param: {string} text Old text.
return: {Array.<string|Array.<boolean>>} Two element Array, containing the

patch_addPadding(&$patches)   X-Ref
Add some padding on text start and end so that edges can match something.
Intended to be called only from within patch_apply.

param: {Array.<patch_obj>} patches Array of patch objects.
return: {string} The padding string added to each side.

patch_splitMax(&$patches)   X-Ref
Look through the patches and break up any which are longer than the maximum
limit of the match algorithm.

param: {Array.<patch_obj>} patches Array of patch objects.

patch_toText($patches)   X-Ref
Take a list of patches and return a textual representation.

param: {Array.<patch_obj>} patches Array of patch objects.
return: {string} Text representation of patches.

patch_fromText($textline)   X-Ref
Parse a textual representation of patches and return a list of patch objects.

param: {string} textline Text representation of patches.
return: {Array.<patch_obj>} Array of patch objects.

Class: patch_obj  - X-Ref

Class representing one patch operation.

toString()   X-Ref
Emmulate GNU diff's format.
Header: @@ -382,8 +481,9 @@
Indicies are printed as 1-based, not 0-based.

return: {string} The GNU diff string.

__toString()   X-Ref
No description

charCodeAt($str, $pos)   X-Ref
No description

mb_ord($v)   X-Ref
No description

mb_chr($num)   X-Ref
No description

encodeURI($url)   X-Ref
as in javascript encodeURI() following the MDN description

param: $url
return: string

decodeURI($encoded)   X-Ref
No description

echo_Exception($str)   X-Ref
No description



Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1