* 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
* @private
* @ingroup DifferenceEngine
*/
-class _DiffOp { #FIXME: no longer private!
+class _DiffOp {
var $type;
var $orig;
var $closing;
* @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 ) {
* @private
* @ingroup DifferenceEngine
*/
-class _DiffOp_Delete extends _DiffOp { #FIXME: no longer private!
+class _DiffOp_Delete extends _DiffOp {
var $type = 'delete';
function __construct( $lines ) {
* @private
* @ingroup DifferenceEngine
*/
-class _DiffOp_Add extends _DiffOp { #FIXME: no longer private!
+class _DiffOp_Add extends _DiffOp {
var $type = 'add';
function __construct( $lines ) {
* @private
* @ingroup DifferenceEngine
*/
-class _DiffOp_Change extends _DiffOp { #FIXME: no longer private!
+class _DiffOp_Change extends _DiffOp {
var $type = 'change';
function __construct( $orig, $closing ) {
* @private
* @ingroup DifferenceEngine
*/
-class _DiffEngine { #FIXME: no longer private!
+class _DiffEngine {
const MAX_XREF_LENGTH = 10000;
* [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
* @private
* @ingroup DifferenceEngine
*/
-class Diff extends DiffResult {
+class Diff {
var $edits;
/**
* @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);
}
/**