diff --git a/inc/DifferenceEngine.php b/inc/DifferenceEngine.php index 37b55e10daa8939b1be92102f6e97ceaccc41e5a..933e0c1eea38fabf6b2103ed9cb1e88e71309330 100644 --- a/inc/DifferenceEngine.php +++ b/inc/DifferenceEngine.php @@ -270,27 +270,29 @@ class _DiffEngine { if (empty($ymatches[$line])) continue; $matches = $ymatches[$line]; - reset($matches); - while (list ($junk, $y) = each($matches)) - if (empty($this->in_seq[$y])) { - $k = $this->_lcs_pos($y); - USE_ASSERTS && assert($k > 0); - $ymids[$k] = $ymids[$k-1]; - break; - } - while (list ($junk, $y) = each($matches)) { - if ($y > $this->seq[$k-1]) { - USE_ASSERTS && assert($y < $this->seq[$k]); - // Optimization: this is a common case: - // next match is just replacing previous match. - $this->in_seq[$this->seq[$k]] = false; - $this->seq[$k] = $y; - $this->in_seq[$y] = 1; - } - else if (empty($this->in_seq[$y])) { - $k = $this->_lcs_pos($y); - USE_ASSERTS && assert($k > 0); - $ymids[$k] = $ymids[$k-1]; + $switch = false; + foreach ($matches as $y) { + if(!$switch) { + if (empty($this->in_seq[$y])) { + $k = $this->_lcs_pos($y); + USE_ASSERTS && assert($k > 0); + $ymids[$k] = $ymids[$k-1]; + $switch = true; + } + }else{ + if ($y > $this->seq[$k-1]) { + USE_ASSERTS && assert($y < $this->seq[$k]); + // Optimization: this is a common case: + // next match is just replacing previous match. + $this->in_seq[$this->seq[$k]] = false; + $this->seq[$k] = $y; + $this->in_seq[$y] = 1; + } + else if (empty($this->in_seq[$y])) { + $k = $this->_lcs_pos($y); + USE_ASSERTS && assert($k > 0); + $ymids[$k] = $ymids[$k-1]; + } } } } @@ -876,10 +878,10 @@ class DiffFormatter { /** * Escape string - * + * * Override this method within other formatters if escaping required. * Base class requires $str to be returned WITHOUT escaping. - * + * * @param $str string Text string to escape * @return string The escaped string. */ diff --git a/inc/JpegMeta.php b/inc/JpegMeta.php index d667ce303d88dd53fb429d6edc3f28412a6e90f0..94c276cfa7af94d0c6dbbd05567c17bc18921fb4 100644 --- a/inc/JpegMeta.php +++ b/inc/JpegMeta.php @@ -2522,13 +2522,13 @@ class JpegMeta { $pos = 14; reset($this->_info['adobe']['raw']); - while (list($key) = each($this->_info['adobe']['raw'])) { + foreach ($this->_info['adobe']['raw'] as $value){ $pos = $this->_write8BIM( $data, $pos, - $this->_info['adobe']['raw'][$key]['type'], - $this->_info['adobe']['raw'][$key]['header'], - $this->_info['adobe']['raw'][$key]['data'] ); + $value['type'], + $value['header'], + $value['data'] ); } }