Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/wp-diff.php

    r17781 r19712  
    203203
    204204                // 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 changes
     205                // *_matches tell what rows are "the same" in orig and final. Those pairs will be diffed to get word changes
    206206                //      match is numeric: an index in other column
    207                 //      match is 'X': no match.  It is a new row
     207                //      match is 'X': no match. It is a new row
    208208                // *_rows are column vectors for the orig column and the final column.
    209209                //      row >= 0: an indix of the $orig or $final array
    210210                //      row  < 0: a blank row for that column
    211211                list($orig_matches, $final_matches, $orig_rows, $final_rows) = $this->interleave_changed_lines( $orig, $final );
    212 
    213212
    214213                // These will hold the word changes as determined by an inline diff
    … …  
    232231                                        $diff_ratio = $stripped_matches / $stripped_diff;
    233232                                        if ( $diff_ratio > $this->_diff_threshold )
    234                                                 continue; // Too different.  Don't save diffs.
     233                                                continue; // Too different. Don't save diffs.
    235234                                }
    236235
    … …  
    242241
    243242                foreach ( array_keys($orig_rows) as $row ) {
    244                         // Both columns have blanks.  Ignore them.
     243                        // Both columns have blanks. Ignore them.
    245244                        if ( $orig_rows[$row] < 0 && $final_rows[$row] < 0 )
    246245                                continue;
    247246
    248                         // If we have a word based diff, use it.  Otherwise, use the normal line.
     247                        // If we have a word based diff, use it. Otherwise, use the normal line.
    249248                        if ( isset( $orig_diffs[$orig_rows[$row]] ) )
    250249                                $orig_line = $orig_diffs[$orig_rows[$row]];
    … …  
    261260                                $final_line = '';
    262261
    263                         if ( $orig_rows[$row] < 0 ) { // Orig is blank.  This is really an added row.
     262                        if ( $orig_rows[$row] < 0 ) { // Orig is blank. This is really an added row.
    264263                                $r .= $this->_added( array($final_line), false );
    265                         } elseif ( $final_rows[$row] < 0 ) { // Final is blank.  This is really a deleted row.
     264                        } elseif ( $final_rows[$row] < 0 ) { // Final is blank. This is really a deleted row.
    266265                                $r .= $this->_deleted( array($orig_line), false );
    267266                        } else { // A true changed row.
    … …  
    289288        function interleave_changed_lines( $orig, $final ) {
    290289
    291                 // Contains all pairwise string comparisons.  Keys are such that this need only be a one dimensional array.
     290                // Contains all pairwise string comparisons. Keys are such that this need only be a one dimensional array.
    292291                $matches = array();
    293292                foreach ( array_keys($orig) as $o ) {
    … …  
    310309                                continue;
    311310
    312                         // First match for these guys.  Must be best match
     311                        // First match for these guys. Must be best match
    313312                        if ( !isset($orig_matches[$o]) && !isset($final_matches[$f]) ) {
    314313                                $orig_matches[$o] = $f;
    … …  
    330329                ksort($final_matches);
    331330
    332 
    333331                // Stores rows and blanks for each column.
    334332                $orig_rows = $orig_rows_copy = array_keys($orig_matches);
    … …  
    343341                        if ( false === $final_pos ) { // This orig is paired with a blank final.
    344342                                array_splice( $final_rows, $orig_pos, 0, -1 );
    345                         } elseif ( $final_pos < $orig_pos ) { // This orig's match is up a ways.  Pad final with blank rows.
     343                        } elseif ( $final_pos < $orig_pos ) { // This orig's match is up a ways. Pad final with blank rows.
    346344                                $diff_pos = $final_pos - $orig_pos;
    347345                                while ( $diff_pos < 0 )
    348346                                        array_splice( $final_rows, $orig_pos, 0, $diff_pos++ );
    349                         } elseif ( $final_pos > $orig_pos ) { // This orig's match is down a ways.  Pad orig with blank rows.
     347                        } elseif ( $final_pos > $orig_pos ) { // This orig's match is down a ways. Pad orig with blank rows.
    350348                                $diff_pos = $orig_pos - $final_pos;
    351349                                while ( $diff_pos < 0 )
    … …  
    353351                        }
    354352                }
    355 
    356353
    357354                // Pad the ends with blank rows if the columns aren't the same length
    … …  
    428425                $difference = array_sum( array_map( array(&$this, 'difference'), $chars1, $chars2 ) );
    429426
    430                 // $string1 has zero length? Odd.  Give huge penalty by not dividing.
     427                // $string1 has zero length? Odd. Give huge penalty by not dividing.
    431428                if ( !$string1 )
    432429                        return $difference;
    … …  
    474471
    475472}
    476 
    477 ?>
Note: See TracChangeset for help on using the changeset viewer.