function diff_result($all, $ent, $newtname, $oldtname, $obj) { $ofile = fopen($oldtname, 'r'); $nfile = fopen($newtname, 'r'); // Get the first real line $line = nextLine($obj); $index = 0; $listing = array(); $curoline = 1; $curnline = 1; while (!endOfFile($obj)) { // Get the first line of this range $oline = 0; sscanf($line, '@@ -%d', $oline); $line = substr($line, strpos($line, '+')); $nline = 0; sscanf($line, '+%d', $nline); while ($curoline < $oline || $curnline < $nline) { if ($all) { $listing[$index]['rev1diffclass'] = 'diff'; $listing[$index]['rev2diffclass'] = 'diff'; } if ($curoline < $oline) { $nl = fgets($ofile); if ($all) { $line = rtrim($nl); if ($ent) { $line = replaceEntities($line); } else { $line = toOutputEncoding($line); } if (strip_tags($line) == '') { $line = ' '; } $listing[$index]['rev1line'] = wrapInCodeTagIfNecessary($line); } $curoline++; } else { if ($all) { $listing[$index]['rev1line'] = ' '; } } if ($curnline < $nline) { $nl = fgets($nfile); if ($all) { $line = rtrim($nl); if ($ent) { $line = replaceEntities($line); } else { $line = toOutputEncoding($line); } if (strip_tags($line) == '') { $line = ' '; } $listing[$index]['rev2line'] = wrapInCodeTagIfNecessary($line); } $curnline++; } else { if ($all) { $listing[$index]['rev2line'] = ' '; } } if ($all) { $listing[$index]['rev1lineno'] = 0; $listing[$index]['rev2lineno'] = 0; $index++; } } if (!$all) { // Output the line numbers $listing[$index]['rev1lineno'] = $oline; $listing[$index]['rev2lineno'] = $nline; $index++; } $fin = false; while (!endOfFile($obj) && !$fin) { $line = nextLine($obj); if ($line === false || $line === '' || strncmp($line, '@@', 2) == 0) { $fin = true; } else { $listing[$index]['rev1lineno'] = 0; $listing[$index]['rev2lineno'] = 0; $mod = $line[0]; $line = rtrim(substr($line, 1)); if ($ent) { $line = replaceEntities($line); } else { $line = toOutputEncoding($line); } if (strip_tags($line) == '') { $line = ' '; } $text = wrapInCodeTagIfNecessary($line); $listing[$index]['rev1line'] = $text; switch ($mod) { case '-': $listing[$index]['rev1diffclass'] = 'diffdeleted'; $listing[$index]['rev2diffclass'] = 'diff'; $listing[$index]['rev1line'] = $text; $listing[$index]['rev2line'] = ' '; fgets($ofile); $curoline++; break; case '+': // Try to mark "changed" line sensibly if (!empty($listing[$index - 1]) && empty($listing[$index - 1]['rev1lineno']) && @$listing[$index - 1]['rev1diffclass'] == 'diffdeleted' && @$listing[$index - 1]['rev2diffclass'] == 'diff') { $i = $index - 1; while (!empty($listing[$i - 1]) && empty($listing[$i - 1]['rev1lineno']) && $listing[$i - 1]['rev1diffclass'] == 'diffdeleted' && $listing[$i - 1]['rev2diffclass'] == 'diff') { $i--; } $listing[$i]['rev1diffclass'] = 'diffchanged'; $listing[$i]['rev2diffclass'] = 'diffchanged'; $listing[$i]['rev2line'] = $text; fgets($nfile); $curnline++; // Don't increment the current index count $index--; } else { $listing[$index]['rev1diffclass'] = 'diff'; $listing[$index]['rev2diffclass'] = 'diffadded'; $listing[$index]['rev1line'] = ' '; $listing[$index]['rev2line'] = $text; fgets($nfile); $curnline++; } break; default: $listing[$index]['rev1diffclass'] = 'diff'; $listing[$index]['rev2diffclass'] = 'diff'; $nl = fgets($ofile); $line = rtrim($nl); if ($ent) { $line = replaceEntities($line); } else { $line = toOutputEncoding($line); } if (strip_tags($line) == '') { $line = ' '; } $listing[$index]['rev1line'] = wrapInCodeTagIfNecessary($line); $curoline++; $nl = fgets($nfile); $line = rtrim($nl); if ($ent) { $line = replaceEntities($line); } else { $line = toOutputEncoding($line); } if (strip_tags($line) == '') { $line = ' '; } $listing[$index]['rev2line'] = wrapInCodeTagIfNecessary($line); $curnline++; break; } } if (!$fin) { $index++; } } } // Output the rest of the files if ($all) { while (!feof($ofile) || !feof($nfile)) { $listing[$index]['rev1diffclass'] = 'diff'; $listing[$index]['rev2diffclass'] = 'diff'; $line = rtrim(fgets($ofile)); if ($ent) { $line = replaceEntities($line); } else { $line = toOutputEncoding($line); } if (strip_tags($line) == '') { $line = ' '; } if (!feof($ofile)) { $listing[$index]['rev1line'] = wrapInCodeTagIfNecessary($line); } else { $listing[$index]['rev1line'] = ' '; } $line = rtrim(fgets($nfile)); if ($ent) { $line = replaceEntities(rtrim(fgets($nfile))); } else { $line = toOutputEncoding($line); } if (strip_tags($line) == '') { $line = ' '; } if (!feof($nfile)) { $listing[$index]['rev2line'] = wrapInCodeTagIfNecessary($line); } else { $listing[$index]['rev2line'] = ' '; } $listing[$index]['rev1lineno'] = 0; $listing[$index]['rev2lineno'] = 0; $index++; } } fclose($ofile); fclose($nfile); return $listing; }
} while (!$done); if (strpos($line, 'msgid_plural') !== false) { $msgids['msgid_plural'] = trim(preg_replace('~msgid_plural\\s*~', '', $line), '"'); do { $line = nextLine(); $done = strpos($line, 'msgstr') !== false; if (!$done) { $msgids['msgid_plural'] .= trim($line, '"'); } } while (!$done); } $msgstrs = array(); preg_match('~(msgstr[\\[\\d+\\]]*)~', $line, $matches); $msgstrs[$matches[1]] = trim(preg_replace('~msgstr[\\[\\d+\\]]*\\s*~', '', $line), '"'); do { $line = nextLine(); if (strpos($line, 'msgstr') !== false) { preg_match('~(msgstr[\\[\\d+\\]]*)~', $line, $matches); $msgstrs[$matches[1]] = trim(preg_replace('~msgstr[\\[\\d+\\]]*\\s*~', '', $line), '"'); } else { $done = empty($line); if (!$done) { $msgstrs[$matches[1]] .= trim($line, '"'); } } } while (!$done); if (!empty($msgids)) { foreach ($msgids as $id => $msgid) { $listed = $double = $single = false; if (strpos(stripEscaped($msgid), '"') === false) { //no English "