Changeset 882 for trunk/common/diff.php
- Timestamp:
- 12/28/07 19:52:43 (4 years ago)
- File:
-
- 1 edited
-
trunk/common/diff.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/common/diff.php
r880 r882 118 118 function split_string($string, $substring, $op_name) { 119 119 // sentinel character 120 $string .= " #";121 $substring .= " #";120 $string .= "\n"; 121 $substring .= "\n"; 122 122 $N = strlen($string); 123 123 $M = strlen($substring); … … 126 126 for ($i = 0, $j = -1; $i < $M; ++$i) { 127 127 for ($prev = $j++; $j < $N && $string[$j] != $substring[$i]; ++$j); 128 log_assert($j < $N); 129 if ($i == $M-1) { 130 --$j; 131 } 128 log_assert($j < $N && $string[$j] == $substring[$i]); 132 129 if ($j-$prev-1 > 0) { 133 130 $result[] = array('type' => $op_name, 'string' => substr($string, $prev+1, $j-$prev-1)); 134 131 } 135 $result[] = array('type' => 'normal', 'string' => $string[$j]); 132 if ($i < $M-1) { 133 $result[] = array('type' => 'normal', 'string' => $string[$j]); 134 } 136 135 } 137 136
Note: See TracChangeset
for help on using the changeset viewer.
![[infoarena] development](/chrome/site/logo.png)