Output a colored diff more often

Previously, any diff output from stdin had to be fully read. This caused `svn
log --diff | colordiff` to block until the fully history has been read.

In order to make colordiff output the colored diff more early, the program has
been changed to read the fewest lines necessary for detecting the diff format,
and read input line-by-line. As a side-effect, the memory usage of this program
possibly drops a little.

Note: in the current form, one needs to use `--difftype=diffu` to prevent `svn
log` output from being treated as side-by-side diff. This happens because
colordiff finds a pipe character in `r123 | committer | ...`. When parsing the
side-by-side format ("diff -y"), input is still fully read in order to determine
the marker positions.
Make detect_diff_type accept a single line

Instead of iterating through the inputstream array each time when searching for
a diff type, check only a newly added line. Put the iteration responsibility
into the caller for the diffy case. Note that the body of the foreach-loop has
not changed, it is only indented to the left after removing the foreach.

While we are at it, prevent the global diff_type from being modified by
detect_diff_type (just return it, the caller will set it anyway).
Fix detection for sdiff -l (--left-column) format
Start processing data before reading input with diffy

This was an attempt to recognize `svn log --diff` better, but that failed here.
Anyway, the changes made here avoid looping through the input data twice at the
cost of some additional complexity in the inner loop. It also allows data to be
processed as soon as it is available instead of reading everything in memory
first before processing data.
Ignore CVS markers, delayed tab expansion for diffy

Ignore certain markers which completely broke CVS diff detection. Also, do not
expand tabs for every diff format, just for side-by-side because that is the
only place where it matters to colordiff. As a result, the output for diffs that
were erroneously detected as a side-by-side diff have changed.
Detect earlier that the format is not sdiff

Count the columns that are possibly a marker for sdiff. If any column (ignoring
CVS and diff command lines) does not contain a marker, the column is not
considered a marker anymore.

(The following is skipped when --difftype is set)
Whenever no marker columns are found, if another diff type can be recognized,
that one is used.

This fixes blocking behavior of `svn log --diff | colordiff`.
Add test for svn log --diff format
Avoid reading input again if it was closed

After

    commit 0b31b294b7e2295c2df231080db0601f72a242c5
    Author: Peter Wu <lekensteyn@gmail.com>
    Date:   Sat Feb 9 15:15:27 2013 +0100

        Output a colored diff more often

the input file descriptor would be re-opened when closed before the colorization
process. This behavior was observed when starting colordiff without arguments
(interactive mode) and pressing ^D (EOF). Previously, colordiff would exit (as
expected), but after the above commit, it did not, you had to ^D again. This
patch restores the old behavior.
Merge pull request #7 from Lekensteyn/current

Merging this pull request because I don't see any reasons not to, having reviewed the code.