Index: wp-includes/Text/Diff.php
===================================================================
--- wp-includes/Text/Diff.php	(revision 10876)
+++ wp-includes/Text/Diff.php	(working copy)
@@ -6,10 +6,10 @@
  * The original PHP version of this code was written by Geoffrey T. Dairiki
  * <dairiki@dairiki.org>, and is used/adapted with his permission.
  *
- * $Horde: framework/Text_Diff/Diff.php,v 1.26 2008/01/04 10:07:49 jan Exp $
+ * $Horde: framework/Text_Diff/Diff.php,v 1.27 2008/02/24 10:46:46 jan Exp $
  *
  * Copyright 2004 Geoffrey T. Dairiki <dairiki@dairiki.org>
- * Copyright 2004-2008 The Horde Project (http://www.horde.org/)
+ * Copyright 2004-2009 The Horde Project (http://www.horde.org/)
  *
  * See the enclosed file COPYING for license information (LGPL). If you did
  * not receive this file, see http://opensource.org/licenses/lgpl-license.php.
@@ -48,8 +48,8 @@
         } else {
             $engine = basename($engine);
         }
-
-        // WP #7391
+		
+        // WP path fix
         require_once dirname(__FILE__).'/Diff/Engine/' . $engine . '.php';
         $class = 'Text_Diff_Engine_' . $engine;
         $diff_engine = new $class();
@@ -64,6 +64,46 @@
     {
         return $this->_edits;
     }
+    
+    /**
+     * returns the number of new (added) lines in a given diff.
+     *
+     * @since Text_Diff 1.1.0
+     * @since Horde 3.2
+     *
+     * @return integer The number of new lines
+     */
+    function countAddedLines()
+    {
+        $count = 0;
+        foreach ($this->_edits as $edit) {
+            if (is_a($edit, 'Text_Diff_Op_add') ||
+                is_a($edit, 'Text_Diff_Op_change')) {
+                $count += $edit->nfinal();
+            }
+        }
+        return $count;
+    }
+    
+    /**
+     * Returns the number of deleted (removed) lines in a given diff.
+     *
+     * @since Text_Diff 1.1.0
+     * @since Horde 3.2
+     *
+     * @return integer The number of deleted lines
+     */
+    function countDeletedLines()
+    {
+        $count = 0;
+        foreach ($this->_edits as $edit) {
+            if (is_a($edit, 'Text_Diff_Op_delete') ||
+                is_a($edit, 'Text_Diff_Op_change')) {
+                $count += $edit->norig();
+            }
+        }
+        return $count;
+    }
 
     /**
      * Computes a reversed diff.
Index: wp-includes/Text/Diff/Engine/native.php
===================================================================
--- wp-includes/Text/Diff/Engine/native.php	(revision 10876)
+++ wp-includes/Text/Diff/Engine/native.php	(working copy)
@@ -1,9 +1,8 @@
 <?php
 /**
- * $Horde: framework/Text_Diff/Diff/Engine/native.php,v 1.10 2008/01/04 10:27:53 jan Exp $
+ * Class used internally by Text_Diff to actually compute the diffs.
  *
- * Class used internally by Text_Diff to actually compute the diffs. This
- * class is implemented using native PHP code.
+ * This class is implemented using native PHP code.
  *
  * The algorithm used here is mostly lifted from the perl module
  * Algorithm::Diff (version 1.06) by Ned Konz, which is available at:
@@ -19,8 +18,10 @@
  * Geoffrey T. Dairiki <dairiki@dairiki.org>. The original PHP version of this
  * code was written by him, and is used/adapted with his permission.
  *
- * Copyright 2004-2008 The Horde Project (http://www.horde.org/)
+ * $Horde: framework/Text_Diff/Diff/Engine/native.php,v 1.11 2008/09/10 08:34:37 jan Exp $
  *
+ * Copyright 2004-2009 The Horde Project (http://www.horde.org/)
+ *
  * See the enclosed file COPYING for license information (LGPL). If you did
  * not receive this file, see http://opensource.org/licenses/lgpl-license.php.
  *
Index: wp-includes/Text/Diff/Engine/string.php
===================================================================
--- wp-includes/Text/Diff/Engine/string.php	(revision 10876)
+++ wp-includes/Text/Diff/Engine/string.php	(working copy)
@@ -10,10 +10,10 @@
  * echo $renderer->render($diff);
  * </code>
  *
- * $Horde: framework/Text_Diff/Diff/Engine/string.php,v 1.7 2008/01/04 10:07:50 jan Exp $
+ * $Horde: framework/Text_Diff/Diff/Engine/string.php,v 1.9 2008/09/10 08:13:43 jan Exp $
  *
  * Copyright 2005 Örjan Persson <o@42mm.org>
- * Copyright 2005-2008 The Horde Project (http://www.horde.org/)
+ * Copyright 2005-2009 The Horde Project (http://www.horde.org/)
  *
  * See the enclosed file COPYING for license information (LGPL). If you did
  * not receive this file, see http://opensource.org/licenses/lgpl-license.php.
@@ -48,17 +48,20 @@
             $unified = strpos($diff, '---');
             if ($context === $unified) {
                 return PEAR::raiseError('Type of diff could not be detected');
-            } elseif ($context === false || $context === false) {
+            } elseif ($context === false || $unified === false) {
                 $mode = $context !== false ? 'context' : 'unified';
             } else {
                 $mode = $context < $unified ? 'context' : 'unified';
             }
         }
 
-        // split by new line and remove the diff header
+        // Split by new line and remove the diff header, if there is one.
         $diff = explode("\n", $diff);
-        array_shift($diff);
-        array_shift($diff);
+        if (($mode == 'context' && strpos($diff[0], '***') === 0) ||
+            ($mode == 'unified' && strpos($diff[0], '---') === 0)) {
+            array_shift($diff);
+            array_shift($diff);
+        }
 
         if ($mode == 'context') {
             return $this->parseContextDiff($diff);
@@ -85,7 +88,7 @@
                 do {
                     $diff1[] = substr($diff[$i], 1);
                 } while (++$i < $end && substr($diff[$i], 0, 1) == ' ');
-                $edits[] = &new Text_Diff_Op_copy($diff1);
+                $edits[] = new Text_Diff_Op_copy($diff1);
                 break;
 
             case '+':
@@ -93,7 +96,7 @@
                 do {
                     $diff1[] = substr($diff[$i], 1);
                 } while (++$i < $end && substr($diff[$i], 0, 1) == '+');
-                $edits[] = &new Text_Diff_Op_add($diff1);
+                $edits[] = new Text_Diff_Op_add($diff1);
                 break;
 
             case '-':
@@ -107,9 +110,9 @@
                     $diff2[] = substr($diff[$i++], 1);
                 }
                 if (count($diff2) == 0) {
-                    $edits[] = &new Text_Diff_Op_delete($diff1);
+                    $edits[] = new Text_Diff_Op_delete($diff1);
                 } else {
-                    $edits[] = &new Text_Diff_Op_change($diff1, $diff2);
+                    $edits[] = new Text_Diff_Op_change($diff1, $diff2);
                 }
                 break;
 
@@ -175,7 +178,7 @@
                 $array[] = substr($diff[$j++], 2);
             }
             if (count($array) > 0) {
-                $edits[] = &new Text_Diff_Op_copy($array);
+                $edits[] = new Text_Diff_Op_copy($array);
             }
 
             if ($i < $max_i) {
@@ -189,21 +192,21 @@
                             $diff2[] = substr($diff[$j++], 2);
                         }
                     } while (++$i < $max_i && substr($diff[$i], 0, 1) == '!');
-                    $edits[] = &new Text_Diff_Op_change($diff1, $diff2);
+                    $edits[] = new Text_Diff_Op_change($diff1, $diff2);
                     break;
 
                 case '+':
                     do {
                         $diff1[] = substr($diff[$i], 2);
                     } while (++$i < $max_i && substr($diff[$i], 0, 1) == '+');
-                    $edits[] = &new Text_Diff_Op_add($diff1);
+                    $edits[] = new Text_Diff_Op_add($diff1);
                     break;
 
                 case '-':
                     do {
                         $diff1[] = substr($diff[$i], 2);
                     } while (++$i < $max_i && substr($diff[$i], 0, 1) == '-');
-                    $edits[] = &new Text_Diff_Op_delete($diff1);
+                    $edits[] = new Text_Diff_Op_delete($diff1);
                     break;
                 }
             }
@@ -215,14 +218,14 @@
                     do {
                         $diff2[] = substr($diff[$j++], 2);
                     } while ($j < $max_j && substr($diff[$j], 0, 1) == '+');
-                    $edits[] = &new Text_Diff_Op_add($diff2);
+                    $edits[] = new Text_Diff_Op_add($diff2);
                     break;
 
                 case '-':
                     do {
                         $diff2[] = substr($diff[$j++], 2);
                     } while ($j < $max_j && substr($diff[$j], 0, 1) == '-');
-                    $edits[] = &new Text_Diff_Op_delete($diff2);
+                    $edits[] = new Text_Diff_Op_delete($diff2);
                     break;
                 }
             }
