Lines Matching refs:diff
31 * @param string $diff The diff content.
38 public function diff($diff, $mode = 'autodetect') function in Horde_Text_Diff_Engine_String
42 if (strpos($diff, "\r\n") !== false) {
44 } elseif (strpos($diff, "\r") !== false) {
49 if (substr($diff, -strlen($lnbr)) != $lnbr) {
50 $diff .= $lnbr;
58 $context = strpos($diff, '***');
59 $unified = strpos($diff, '---');
70 $diff = explode($lnbr, $diff);
71 if (($mode == 'context' && strpos($diff[0], '***') === 0) ||
72 ($mode == 'unified' && strpos($diff[0], '---') === 0)) {
73 array_shift($diff);
74 array_shift($diff);
78 return $this->parseContextDiff($diff);
80 return $this->parseUnifiedDiff($diff);
87 * @param array $diff Array of lines.
91 public function parseUnifiedDiff($diff) argument
94 $end = count($diff) - 1;
97 switch (substr($diff[$i], 0, 1)) {
100 $diff1[] = substr($diff[$i], 1);
101 } while (++$i < $end && substr($diff[$i], 0, 1) == ' ');
108 $diff1[] = substr($diff[$i], 1);
109 } while (++$i < $end && substr($diff[$i], 0, 1) == '+');
117 $diff1[] = substr($diff[$i], 1);
118 } while (++$i < $end && substr($diff[$i], 0, 1) == '-');
120 while ($i < $end && substr($diff[$i], 0, 1) == '+') {
121 $diff2[] = substr($diff[$i++], 1);
142 * @param array $diff Array of lines.
146 public function parseContextDiff(&$diff) argument
150 $end = count($diff) - 1;
155 $i < $end && substr($diff[$i], 0, 3) == '***';
158 $max_i < $end && substr($diff[$max_i], 0, 3) != '---';
161 $j < $end && substr($diff[$j], 0, 3) == '---';
164 $max_j < $end && substr($diff[$max_j], 0, 3) != '***';
172 strcmp($diff[$i], $diff[$j]) == 0) {
173 $array[] = substr($diff[$i], 2);
179 if ($diff[$i] != '' && substr($diff[$i], 0, 1) != ' ') {
182 $array[] = substr($diff[$i++], 2);
186 if ($diff[$j] != '' && substr($diff[$j], 0, 1) != ' ') {
189 $array[] = substr($diff[$j++], 2);
197 switch (substr($diff[$i], 0, 1)) {
201 $diff1[] = substr($diff[$i], 2);
202 if ($j < $max_j && substr($diff[$j], 0, 1) == '!') {
203 $diff2[] = substr($diff[$j++], 2);
205 } while (++$i < $max_i && substr($diff[$i], 0, 1) == '!');
211 $diff1[] = substr($diff[$i], 2);
212 } while (++$i < $max_i && substr($diff[$i], 0, 1) == '+');
218 $diff1[] = substr($diff[$i], 2);
219 } while (++$i < $max_i && substr($diff[$i], 0, 1) == '-');
227 switch (substr($diff[$j], 0, 1)) {
230 $diff2[] = substr($diff[$j++], 2);
231 } while ($j < $max_j && substr($diff[$j], 0, 1) == '+');
237 $diff2[] = substr($diff[$j++], 2);
238 } while ($j < $max_j && substr($diff[$j], 0, 1) == '-');