Changeset 702 for trunk/forum/includes/diff/engine.php
- Timestamp:
- Mar 31, 2010, 6:32:40 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/forum/includes/diff/engine.php
r400 r702 3 3 * 4 4 * @package diff 5 * @version $Id : engine.php 8765 2008-08-16 22:18:25Z aptx$5 * @version $Id$ 6 6 * @copyright (c) 2006 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 18 18 19 19 /** 20 * Code from pear.php.net, Text_Diff-1. 0.0 package20 * Code from pear.php.net, Text_Diff-1.1.0 package 21 21 * http://pear.php.net/package/Text_Diff/ (native engine) 22 22 * … … 50 50 class diff_engine 51 51 { 52 /** 53 * If set to true we trim all lines before we compare them. This ensures that sole space/tab changes do not trigger diffs. 54 */ 55 var $skip_whitespace_changes = true; 56 52 57 function diff(&$from_lines, &$to_lines, $preserve_cr = true) 53 58 { … … 86 91 for ($skip = 0; $skip < $n_from && $skip < $n_to; $skip++) 87 92 { 88 if ( $from_lines[$skip] !== $to_lines[$skip])93 if (trim($from_lines[$skip]) !== trim($to_lines[$skip])) 89 94 { 90 95 break; … … 99 104 for ($endskip = 0; --$xi > $skip && --$yi > $skip; $endskip++) 100 105 { 101 if ( $from_lines[$xi] !== $to_lines[$yi])106 if (trim($from_lines[$xi]) !== trim($to_lines[$yi])) 102 107 { 103 108 break; … … 109 114 for ($xi = $skip; $xi < $n_from - $endskip; $xi++) 110 115 { 111 $xhash[$from_lines[$xi]] = 1;116 if ($this->skip_whitespace_changes) $xhash[trim($from_lines[$xi])] = 1; else $xhash[$from_lines[$xi]] = 1; 112 117 } 113 118 114 119 for ($yi = $skip; $yi < $n_to - $endskip; $yi++) 115 120 { 116 $line = $to_lines[$yi];121 $line = ($this->skip_whitespace_changes) ? trim($to_lines[$yi]) : $to_lines[$yi]; 117 122 118 123 if (($this->ychanged[$yi] = empty($xhash[$line]))) … … 127 132 for ($xi = $skip; $xi < $n_from - $endskip; $xi++) 128 133 { 129 $line = $from_lines[$xi];134 $line = ($this->skip_whitespace_changes) ? trim($from_lines[$xi]) : $from_lines[$xi]; 130 135 131 136 if (($this->xchanged[$xi] = empty($yhash[$line]))) … … 141 146 142 147 // Merge edits when possible. 143 $this->_shift_boundaries($from_lines, $this->xchanged, $this->ychanged); 144 $this->_shift_boundaries($to_lines, $this->ychanged, $this->xchanged); 148 if ($this->skip_whitespace_changes) 149 { 150 $from_lines_clean = array_map('trim', $from_lines); 151 $to_lines_clean = array_map('trim', $to_lines); 152 153 $this->_shift_boundaries($from_lines_clean, $this->xchanged, $this->ychanged); 154 $this->_shift_boundaries($to_lines_clean, $this->ychanged, $this->xchanged); 155 156 unset($from_lines_clean, $to_lines_clean); 157 } 158 else 159 { 160 $this->_shift_boundaries($from_lines, $this->xchanged, $this->ychanged); 161 $this->_shift_boundaries($to_lines, $this->ychanged, $this->xchanged); 162 } 145 163 146 164 // Compute the edit operations.
Note:
See TracChangeset
for help on using the changeset viewer.