Merge "resourceloader: Use "\n" instead of ";" as separator for scripts"
[lhc/web/wiklou.git] / includes / diff / TableDiffFormatter.php
index f1826ed..bcae746 100644 (file)
@@ -204,16 +204,13 @@ class TableDiffFormatter extends DiffFormatter {
                # Notice that WordLevelDiff returns HTML-escaped output.
                # Hence, we will be calling addedLine/deletedLine without HTML-escaping.
 
-               $line = array_shift( $del );
-               while ( $line ) {
-                       $aline = array_shift( $add );
-                       $this->writeOutput( '<tr>' . $this->deletedLine( $line ) .
-                               $this->addedLine( $aline ) . "</tr>\n" );
-                       $line = array_shift( $del );
-               }
-               foreach ( $add as $line ) { # If any leftovers
-                       $this->writeOutput( '<tr>' . $this->emptyLine() .
-                               $this->addedLine( $line ) . "</tr>\n" );
+               $ndel = count( $del );
+               $nadd = count( $add );
+               $n = max( $ndel, $nadd );
+               for ( $i = 0; $i < $n; $i++ ) {
+                       $delLine = $i < $ndel ? $this->deletedLine( $del[$i] ) : $this->emptyLine();
+                       $addLine = $i < $nadd ? $this->addedLine( $add[$i] ) : $this->emptyLine();
+                       $this->writeOutput( "<tr>{$delLine}{$addLine}</tr>\n" );
                }
        }