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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. http://www.gnu.org/licenses/gpl.html Revision: $Revision: 1.3 $ **/ /* * Convert texts into arrays such that the newlines are conserved */ function splitWithNL($text) { $array = split("\n", $text); for ($i=0; $i 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. http://www.gnu.org/licenses/gpl.html Revision: $Revision: 1.12 $ **/ $DiffFunction='php_Diff'; /** * Checks, if there is a line number-entry in $r_array for $line, * that is behind $where. * $where will be assigned the line-number, if true **/ function nextOccurence($line, &$r_array, $where) { $tmp = $r_array[$line]; if (!$tmp) return FALSE; foreach($tmp as $nr) { if ($where<=$nr) { $where = $nr; return $nr; } } return FALSE; } /** * Compute the manhatten distance of two points **/ function dist($a,$b) { $d1=$b[1]-$a[1]; $d2=$b[2]-$a[2]; return $d2+$d1; } /* * Computes the difference between two string linewise. * The output is the same format * as the GNU diff command without any parameters. * Note: Since GNU diff starts counting with 1, and arrays start counting with * 0, you have to subtract one from each line number to get the real one. */ function php_Diff($text1, $text2) { $array1 = splitWithNL($text1); $array2 = splitWithNL($text2); /* Build up array with the line as key and a list of line numbers as value */ foreach($array1 as $nr => $line) { $r_array1[$line][] = $nr; } foreach($array2 as $nr => $line) { $r_array2[$line][] = $nr; } $result=""; $a[1]=0; /* counter for array1 */ $a[2]=0; /* counter for array2 */ $actions=Array(); while($a[1]