CVSLIB_DIFF_HEADER, 'oldline' => $regs[1], 'newline' => $regs[2], 'contents'> array()); $data['function'] = isset($regs[3])?$regs[3]:''; $state = CVSLIB_DIFF_DUMP; } else if ($state != CVSLIB_DIFF_EMPTY) { /* We are in a chunk, so split out the action (+/-) and the line */ preg_match('/^([\+\- ])(.*)/', $line, $regs); if (sizeof($regs) > 2) { $action = $regs[1]; $content = $regs[2]; } else { $action = ' '; $content = ''; } if ($action == '+') { /* This is just an addition line */ if ($state == CVSLIB_DIFF_DUMP || $state == CVSLIB_DIFF_ADD) { /* Start adding to the addition stack */ $cols[0][] = $content; $state = CVSLIB_DIFF_ADD; } else { /* This is inside a change block, so start accumulating lines */ $state = CVSLIB_DIFF_CHANGE; $cols[1][] = $content; } } else if ($action == '-') { /* This is a removal line */ $state = CVSLIB_DIFF_REMOVE; $cols[0][] = $content; } else { /* An empty block with no action */ switch ($state) { case CVSLIB_DIFF_ADD: $data['contents'][] = array('type' => CVSLIB_DIFF_ADD, 'lines' => $cols[0]); break; case CVSLIB_DIFF_REMOVE: /* We have some removal lines pending in our stack, so flush them */ $data['contents'][] = array('type' => CVSLIB_DIFF_REMOVE, 'lines' => $cols[0] ); break; case CVSLIB_DIFF_CHANGE: /* We have both remove and addition lines, so this is a change block */ $data['contents'][] = array('type' => CVSLIB_DIFF_CHANGE, 'old' => $cols[0], 'new' => $cols[1]); break; } $cols = array( array(), array() ); $data['contents'][] = array('type' => CVSLIB_DIFF_EMPTY, 'line' => $content); $state = CVSLIB_DIFF_DUMP; } } } /* Just flush any remaining entries in the columns stack */ switch ($state) { case CVSLIB_DIFF_ADD: $data['contents'][] = array('type' => CVSLIB_DIFF_ADD, 'lines' => $cols[0]); break; case CVSLIB_DIFF_REMOVE: /* We have some removal lines pending in our stack, so flush them */ $data['contents'][] = array('type' => CVSLIB_DIFF_REMOVE, 'lines' => $cols[0] ); break; case CVSLIB_DIFF_CHANGE: /* We have both remove and addition lines, so this is a change block */ $data['contents'][] = array('type' => CVSLIB_DIFF_CHANGE, 'old' => $cols[0], 'new' => $cols[1]); break; } if (isset($data)) { $ret[] = $data; } return $ret; } function dRow( $lefthead, $righthead, $headfunc ) { ?>
| OLD | NEW |
|---|