Text_Diff_Op_delete example

$delete[] = $from_lines[$xi++];
            }

            $add = array();
            while ($yi < $n_to && $this->ychanged[$yi]) {
                $add[] = $to_lines[$yi++];
            }

            if ($delete && $add) {
                $edits[] = new Text_Diff_Op_change($delete$add);
            } elseif ($delete) {
                $edits[] = new Text_Diff_Op_delete($delete);
            } elseif ($add) {
                $edits[] = new Text_Diff_Op_add($add);
            }
        }

        return $edits;
    }

    /** * Divides the Largest Common Subsequence (LCS) of the sequences (XOFF, * XLIM) and (YOFF, YLIM) into NCHUNKS approximately equally sized * segments. * * 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 that (X0, Y0) == * (XOFF, YOFF) and (X[NCHUNKS], Y[NCHUNKS]) == (XLIM, YLIM). * * This function assumes that the first lines of the specified portions of * the two files do not match, and likewise that the last lines do not * match. The caller must trim matching lines from the beginning and end * of the portions it is going to specify. */
                assert($match[1] - $from_line_no == $match[4] - $to_line_no);
                array_push($edits,
                    new Text_Diff_Op_copy(
                        $this->_getLines($from_lines$from_line_no$match[1] - 1),
                        $this->_getLines($to_lines$to_line_no$match[4] - 1)));
            }

            switch ($match[3]) {
            case 'd':
                // deleted lines                 array_push($edits,
                    new Text_Diff_Op_delete(
                        $this->_getLines($from_lines$from_line_no$match[2])));
                $to_line_no++;
                break;

            case 'c':
                // changed lines                 array_push($edits,
                    new Text_Diff_Op_change(
                        $this->_getLines($from_lines$from_line_no$match[2]),
                        $this->_getLines($to_lines$to_line_no$match[5])));
                break;

            
case '-':
                // get changed or removed lines                 $diff2 = array();
                do {
                    $diff1[] = substr($diff[$i], 1);
                } while (++$i < $end && substr($diff[$i], 0, 1) == '-');

                while ($i < $end && substr($diff[$i], 0, 1) == '+') {
                    $diff2[] = substr($diff[$i++], 1);
                }
                if (count($diff2) == 0) {
                    $edits[] = new Text_Diff_Op_delete($diff1);
                } else {
                    $edits[] = new Text_Diff_Op_change($diff1$diff2);
                }
                break;

            default:
                $i++;
                break;
            }
        }

        


    /** * PHP4 constructor. */
    public function Text_Diff_Op_add( $lines ) {
        self::__construct( $lines );
    }

    function Dreverse()
    {
        $reverse = new Text_Diff_Op_delete($this->final);
        return $reverse;
    }

}

/** * @package Text_Diff * @author Geoffrey T. Dairiki <dairiki@dairiki.org> * * @access private */

            switch ($line[0]) {
            case ' ':
                $edits[] = new Text_Diff_Op_copy(array(substr($line, 1)));
                break;

            case '+':
                $edits[] = new Text_Diff_Op_add(array(substr($line, 1)));
                break;

            case '-':
                $edits[] = new Text_Diff_Op_delete(array(substr($line, 1)));
                break;
            }
        }

        return $edits;
    }

}
Home | Imprint | This part of the site doesn't use cookies.