function WordLevelDiff::_split in Diff 5.2
Same name and namespace in other branches
- 5 DiffEngine.php \WordLevelDiff::_split()
- 6.2 DiffEngine.php \WordLevelDiff::_split()
- 6 DiffEngine.php \WordLevelDiff::_split()
- 7.3 DiffEngine.php \WordLevelDiff::_split()
- 7.2 DiffEngine.php \WordLevelDiff::_split()
1 call to WordLevelDiff::_split()
File
- ./
DiffEngine.php, line 974
Class
- WordLevelDiff
- @todo document @private @subpackage DifferenceEngine
Code
function _split($lines) {
$words = array();
$stripped = array();
$first = true;
foreach ($lines as $line) {
# If the line is too long, just pretend the entire line is one big word
# This prevents resource exhaustion problems
if ($first) {
$first = false;
}
else {
$words[] = "\n";
$stripped[] = "\n";
}
if (strlen($line) > $this
->MAX_LINE_LENGTH()) {
$words[] = $line;
$stripped[] = $line;
}
else {
if (preg_match_all('/ ( [^\\S\\n]+ | [0-9_A-Za-z\\x80-\\xff]+ | . ) (?: (?!< \\n) [^\\S\\n])? /xs', $line, $m)) {
$words = array_merge($words, $m[0]);
$stripped = array_merge($stripped, $m[1]);
}
}
}
return array(
$words,
$stripped,
);
}