vendor: Update php-diff with fixes

Version is based on:
* 3cb3f7ce6b
* and https://github.com/chrisboulton/php-diff/pull/50

Also see SOURCE
This commit is contained in:
Heinz Wiesinger 2018-04-16 08:59:56 +02:00 committed by Markus Frosch
parent 8e28f7f9c8
commit 525b3164c0
4 changed files with 24 additions and 20 deletions

View File

@ -1,9 +1,19 @@
#!/bin/bash
set -ex
# version based on current master 3cb3f7ce6bb8b910f5a41ea1887b1faceba6a7d7
# plus https://github.com/chrisboulton/php-diff/pull/50
git clone https://github.com/chrisboulton/php-diff.git git clone https://github.com/chrisboulton/php-diff.git
# Last used commit:
cd php-diff cd php-diff
git checkout f4db229d7ae8dffa0a4f90e1adbec9bf22c93d99
git fetch origin pull/50/head:pr
git checkout a9f124f81a9436138879e56157c6cced52a6d95b
git show -s
rm -rf .git rm -rf .git
rm -rf .gitignore rm -rf .gitignore
rm -rf composer.json rm -rf composer.json
rm -rf example rm -rf example tests phpunit.xml
cd .. cd ..

View File

@ -176,27 +176,21 @@ class Diff_Renderer_Html_Array extends Diff_Renderer_Abstract
{ {
$lines = array_map(array($this, 'ExpandTabs'), $lines); $lines = array_map(array($this, 'ExpandTabs'), $lines);
$lines = array_map(array($this, 'HtmlSafe'), $lines); $lines = array_map(array($this, 'HtmlSafe'), $lines);
$callback = array($this, 'fixMatchedSpaces');
foreach($lines as &$line) { foreach($lines as &$line) {
// $line = preg_replace('# ( +)|^ #e', "\$this->fixSpaces('\\1')", $line); $line = preg_replace_callback('# ( +)|^ #', array($this, 'fixSpaces'), $line);
$line = preg_replace_callback('# ( +)|^ #', $callback, $line);
} }
return $lines; return $lines;
} }
protected function fixMatchedSpaces($m)
{
return $this->fixSpaces($m[1]);
}
/** /**
* Replace a string containing spaces with a HTML representation using  . * Replace a string containing spaces with a HTML representation using  .
* *
* @param string $spaces The string of spaces. * @param string[] $matches Array with preg matches.
* @return string The HTML representation of the string. * @return string The HTML representation of the string.
*/ */
function fixSpaces($spaces='') private function fixSpaces(array $matches)
{ {
$spaces = $matches[1];
$count = strlen($spaces); $count = strlen($spaces);
if($count == 0) { if($count == 0) {
return ''; return '';

View File

@ -128,8 +128,8 @@ class Diff_Renderer_Html_Inline extends Diff_Renderer_Html_Array
foreach($change['changed']['lines'] as $no => $line) { foreach($change['changed']['lines'] as $no => $line) {
$toLine = $change['changed']['offset'] + $no + 1; $toLine = $change['changed']['offset'] + $no + 1;
$html .= '<tr>'; $html .= '<tr>';
$html .= '<th>'.$toLine.'</th>';
$html .= '<th>&nbsp;</th>'; $html .= '<th>&nbsp;</th>';
$html .= '<th>'.$toLine.'</th>';
$html .= '<td class="Right"><span>'.$line.'</span></td>'; $html .= '<td class="Right"><span>'.$line.'</span></td>';
$html .= '</tr>'; $html .= '</tr>';
} }
@ -140,4 +140,4 @@ class Diff_Renderer_Html_Inline extends Diff_Renderer_Html_Array
$html .= '</table>'; $html .= '</table>';
return $html; return $html;
} }
} }

View File

@ -50,12 +50,12 @@ class Diff_SequenceMatcher
/** /**
* @var array The first sequence to compare against. * @var array The first sequence to compare against.
*/ */
private $a = null; private $a = array();
/** /**
* @var array The second sequence. * @var array The second sequence.
*/ */
private $b = null; private $b = array();
/** /**
* @var array Array of characters that are considered junk from the second sequence. Characters are the array key. * @var array Array of characters that are considered junk from the second sequence. Characters are the array key.
@ -86,8 +86,8 @@ class Diff_SequenceMatcher
*/ */
public function __construct($a, $b, $junkCallback=null, $options) public function __construct($a, $b, $junkCallback=null, $options)
{ {
$this->a = null; $this->a = array();
$this->b = null; $this->b = array();
$this->junkCallback = $junkCallback; $this->junkCallback = $junkCallback;
$this->setOptions($options); $this->setOptions($options);
$this->setSequences($a, $b); $this->setSequences($a, $b);
@ -739,4 +739,4 @@ class Diff_SequenceMatcher
return 1; return 1;
} }
} }
} }