scala/scala — pull request #3427 by retronym (2014-01-29 14:28:58+00:00)
Title: SI-8205 Avoid long, slow march to AIIOBE in SourceFile#lineContent

Fixing a regression from SI-8015.

The failure mode is kind of amusing: a while loop in `lineToString`
would count all the way to `Int.MaxValue`, and integer overflow
would foil a bounds check when looking for the 'LF' in 'CR'-'LF'.

Given that we're not a style checker to enforce that source files
end in a new-line, this commit accounts for EOF, and fixed the
overflow problem too.

A JUnit test exercises the bug and a few other variations of
`lineContent`.

Review by @som-snytt / @huitseeker