Changes in trunk/wp-includes/wp-diff.php [19712:17781]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/wp-diff.php
r19712 r17781 203 203 204 204 // Does the aforementioned additional processing 205 // *_matches tell what rows are "the same" in orig and final. Those pairs will be diffed to get word changes205 // *_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. It is a new row207 // 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 210 210 // row < 0: a blank row for that column 211 211 list($orig_matches, $final_matches, $orig_rows, $final_rows) = $this->interleave_changed_lines( $orig, $final ); 212 212 213 213 214 // These will hold the word changes as determined by an inline diff … … 231 232 $diff_ratio = $stripped_matches / $stripped_diff; 232 233 if ( $diff_ratio > $this->_diff_threshold ) 233 continue; // Too different. Don't save diffs.234 continue; // Too different. Don't save diffs. 234 235 } 235 236 … … 241 242 242 243 foreach ( array_keys($orig_rows) as $row ) { 243 // Both columns have blanks. Ignore them.244 // Both columns have blanks. Ignore them. 244 245 if ( $orig_rows[$row] < 0 && $final_rows[$row] < 0 ) 245 246 continue; 246 247 247 // If we have a word based diff, use it. Otherwise, use the normal line.248 // If we have a word based diff, use it. Otherwise, use the normal line. 248 249 if ( isset( $orig_diffs[$orig_rows[$row]] ) ) 249 250 $orig_line = $orig_diffs[$orig_rows[$row]]; … … 260 261 $final_line = ''; 261 262 262 if ( $orig_rows[$row] < 0 ) { // Orig is blank. This is really an added row.263 if ( $orig_rows[$row] < 0 ) { // Orig is blank. This is really an added row. 263 264 $r .= $this->_added( array($final_line), false ); 264 } elseif ( $final_rows[$row] < 0 ) { // Final is blank. This is really a deleted row.265 } elseif ( $final_rows[$row] < 0 ) { // Final is blank. This is really a deleted row. 265 266 $r .= $this->_deleted( array($orig_line), false ); 266 267 } else { // A true changed row. … … 288 289 function interleave_changed_lines( $orig, $final ) { 289 290 290 // Contains all pairwise string comparisons. Keys are such that this need only be a one dimensional array.291 // Contains all pairwise string comparisons. Keys are such that this need only be a one dimensional array. 291 292 $matches = array(); 292 293 foreach ( array_keys($orig) as $o ) { … … 309 310 continue; 310 311 311 // First match for these guys. Must be best match312 // First match for these guys. Must be best match 312 313 if ( !isset($orig_matches[$o]) && !isset($final_matches[$f]) ) { 313 314 $orig_matches[$o] = $f; … … 329 330 ksort($final_matches); 330 331 332 331 333 // Stores rows and blanks for each column. 332 334 $orig_rows = $orig_rows_copy = array_keys($orig_matches); … … 341 343 if ( false === $final_pos ) { // This orig is paired with a blank final. 342 344 array_splice( $final_rows, $orig_pos, 0, -1 ); 343 } elseif ( $final_pos < $orig_pos ) { // This orig's match is up a ways. Pad final with blank rows.345 } elseif ( $final_pos < $orig_pos ) { // This orig's match is up a ways. Pad final with blank rows. 344 346 $diff_pos = $final_pos - $orig_pos; 345 347 while ( $diff_pos < 0 ) 346 348 array_splice( $final_rows, $orig_pos, 0, $diff_pos++ ); 347 } elseif ( $final_pos > $orig_pos ) { // This orig's match is down a ways. Pad orig with blank rows.349 } elseif ( $final_pos > $orig_pos ) { // This orig's match is down a ways. Pad orig with blank rows. 348 350 $diff_pos = $orig_pos - $final_pos; 349 351 while ( $diff_pos < 0 ) … … 351 353 } 352 354 } 355 353 356 354 357 // Pad the ends with blank rows if the columns aren't the same length … … 425 428 $difference = array_sum( array_map( array(&$this, 'difference'), $chars1, $chars2 ) ); 426 429 427 // $string1 has zero length? Odd. Give huge penalty by not dividing.430 // $string1 has zero length? Odd. Give huge penalty by not dividing. 428 431 if ( !$string1 ) 429 432 return $difference; … … 471 474 472 475 } 476 477 ?>
Note: See TracChangeset
for help on using the changeset viewer.