Merge "(bug 40632) Remove CleanupPresentationalAttributes feature"
[lhc/web/wiklou.git] / includes / diff / DairikiDiff.php
index 56cee2e..6a6f930 100644 (file)
@@ -5,6 +5,21 @@
  * Copyright © 2000, 2001 Geoffrey T. Dairiki <dairiki@dairiki.org>
  * You may copy this code freely under the conditions of the GPL.
  *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
  * @file
  * @ingroup DifferenceEngine
  * @defgroup DifferenceEngine DifferenceEngine
@@ -15,7 +30,7 @@
  * @private
  * @ingroup DifferenceEngine
  */
-class _DiffOp { #FIXME: no longer private!
+class _DiffOp {
        var $type;
        var $orig;
        var $closing;
@@ -44,7 +59,7 @@ class _DiffOp { #FIXME: no longer private!
  * @private
  * @ingroup DifferenceEngine
  */
-class _DiffOp_Copy extends _DiffOp { #FIXME: no longer private!
+class _DiffOp_Copy extends _DiffOp {
        var $type = 'copy';
 
        function __construct( $orig, $closing = false ) {
@@ -68,7 +83,7 @@ class _DiffOp_Copy extends _DiffOp { #FIXME: no longer private!
  * @private
  * @ingroup DifferenceEngine
  */
-class _DiffOp_Delete extends _DiffOp { #FIXME: no longer private!
+class _DiffOp_Delete extends _DiffOp {
        var $type = 'delete';
 
        function __construct( $lines ) {
@@ -89,7 +104,7 @@ class _DiffOp_Delete extends _DiffOp { #FIXME: no longer private!
  * @private
  * @ingroup DifferenceEngine
  */
-class _DiffOp_Add extends _DiffOp { #FIXME: no longer private!
+class _DiffOp_Add extends _DiffOp {
        var $type = 'add';
 
        function __construct( $lines ) {
@@ -110,7 +125,7 @@ class _DiffOp_Add extends _DiffOp { #FIXME: no longer private!
  * @private
  * @ingroup DifferenceEngine
  */
-class _DiffOp_Change extends _DiffOp { #FIXME: no longer private!
+class _DiffOp_Change extends _DiffOp {
        var $type = 'change';
 
        function __construct( $orig, $closing ) {
@@ -150,7 +165,7 @@ class _DiffOp_Change extends _DiffOp { #FIXME: no longer private!
  * @private
  * @ingroup DifferenceEngine
  */
-class _DiffEngine { #FIXME: no longer private!
+class _DiffEngine {
 
        const MAX_XREF_LENGTH =  10000;
 
@@ -311,7 +326,7 @@ class _DiffEngine { #FIXME: no longer private!
         * [XOFF, XLIM) and [YOFF, YLIM) into NCHUNKS approximately equally
         * sized segments.
         *
-        * Returns (LCS, PTS).  LCS is the length of the LCS. PTS is an
+        * Returns (LCS, PTS). LCS is the length of the LCS. PTS is an
         * array of NCHUNKS+1 (X, Y) indexes giving the diving points between
         * sub sequences.  The first sub-sequence is contained in [X0, X1),
         * [Y0, Y1), the second in [X1, X2), [Y1, Y2) and so on.  Note
@@ -637,7 +652,7 @@ class _DiffEngine { #FIXME: no longer private!
  * @private
  * @ingroup DifferenceEngine
  */
-class Diff extends DiffResult {
+class Diff {
        var $edits;
 
        /**
@@ -647,36 +662,11 @@ class Diff extends DiffResult {
         * @param $from_lines array An array of strings.
         *                (Typically these are lines from a file.)
         * @param $to_lines array An array of strings.
-        * @param $eng _DiffEngine|null The diff engine to use.
-        */
-       function __construct( $from_lines, $to_lines, $eng = null  ) {
-               if ( !$eng ) {
-                       $eng = new _DiffEngine();
-               }
-
-               $edits = $eng->diff( $from_lines, $to_lines );
-
-               parent::__construct( $edits );
-
-               //$this->_check( $from_lines, $to_lines );
-       }
-}
-
-/**
- * Class representing the result of 'diffin' two sequences of strings.
- * @todo document
- * @private
- * @ingroup DifferenceEngine
- */
-class DiffResult {
-
-       /**
-        * Constructor.
-        *
-        * @param $edits array An array of Edit.
         */
-       function __construct( $edits  ) {
-               $this->edits = $edits;
+       function __construct( $from_lines, $to_lines ) {
+               $eng = new _DiffEngine;
+               $this->edits = $eng->diff( $from_lines, $to_lines );
+               // $this->_check($from_lines, $to_lines);
        }
 
        /**