Changeset 19593 for trunk/wp-includes/wp-diff.php
- Timestamp:
- 12/13/2011 11:45:31 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/wp-diff.php
r17781 r19593 203 203 204 204 // Does the aforementioned additional processing 205 // *_matches tell what rows are "the same" in orig and final. 205 // *_matches tell what rows are "the same" in orig and final. Those pairs will be diffed to get word changes 206 206 // match is numeric: an index in other column 207 // match is 'X': no match. 207 // match is 'X': no match. It is a new row 208 208 // *_rows are column vectors for the orig column and the final column. 209 209 // row >= 0: an indix of the $orig or $final array … … 232 232 $diff_ratio = $stripped_matches / $stripped_diff; 233 233 if ( $diff_ratio > $this->_diff_threshold ) 234 continue; // Too different. 234 continue; // Too different. Don't save diffs. 235 235 } 236 236 … … 242 242 243 243 foreach ( array_keys($orig_rows) as $row ) { 244 // Both columns have blanks. 244 // Both columns have blanks. Ignore them. 245 245 if ( $orig_rows[$row] < 0 && $final_rows[$row] < 0 ) 246 246 continue; 247 247 248 // If we have a word based diff, use it. 248 // If we have a word based diff, use it. Otherwise, use the normal line. 249 249 if ( isset( $orig_diffs[$orig_rows[$row]] ) ) 250 250 $orig_line = $orig_diffs[$orig_rows[$row]]; … … 261 261 $final_line = ''; 262 262 263 if ( $orig_rows[$row] < 0 ) { // Orig is blank. 263 if ( $orig_rows[$row] < 0 ) { // Orig is blank. This is really an added row. 264 264 $r .= $this->_added( array($final_line), false ); 265 } elseif ( $final_rows[$row] < 0 ) { // Final is blank. 265 } elseif ( $final_rows[$row] < 0 ) { // Final is blank. This is really a deleted row. 266 266 $r .= $this->_deleted( array($orig_line), false ); 267 267 } else { // A true changed row. … … 289 289 function interleave_changed_lines( $orig, $final ) { 290 290 291 // Contains all pairwise string comparisons. 291 // Contains all pairwise string comparisons. Keys are such that this need only be a one dimensional array. 292 292 $matches = array(); 293 293 foreach ( array_keys($orig) as $o ) { … … 310 310 continue; 311 311 312 // First match for these guys. 312 // First match for these guys. Must be best match 313 313 if ( !isset($orig_matches[$o]) && !isset($final_matches[$f]) ) { 314 314 $orig_matches[$o] = $f; … … 343 343 if ( false === $final_pos ) { // This orig is paired with a blank final. 344 344 array_splice( $final_rows, $orig_pos, 0, -1 ); 345 } elseif ( $final_pos < $orig_pos ) { // This orig's match is up a ways. 345 } elseif ( $final_pos < $orig_pos ) { // This orig's match is up a ways. Pad final with blank rows. 346 346 $diff_pos = $final_pos - $orig_pos; 347 347 while ( $diff_pos < 0 ) 348 348 array_splice( $final_rows, $orig_pos, 0, $diff_pos++ ); 349 } elseif ( $final_pos > $orig_pos ) { // This orig's match is down a ways. 349 } elseif ( $final_pos > $orig_pos ) { // This orig's match is down a ways. Pad orig with blank rows. 350 350 $diff_pos = $orig_pos - $final_pos; 351 351 while ( $diff_pos < 0 ) … … 428 428 $difference = array_sum( array_map( array(&$this, 'difference'), $chars1, $chars2 ) ); 429 429 430 // $string1 has zero length? Odd. 430 // $string1 has zero length? Odd. Give huge penalty by not dividing. 431 431 if ( !$string1 ) 432 432 return $difference;
Note: See TracChangeset
for help on using the changeset viewer.