Fix comparison with IntStream.EOF

This commit is contained in:
Sam Harwell 2013-02-26 11:02:55 -06:00
parent 645f80971f
commit 03f8d3772f
1 changed files with 3 additions and 3 deletions

View File

@ -169,7 +169,7 @@ public class UnbufferedCharStream implements CharStream {
*/
protected int fill(int n) {
for (int i=0; i<n; i++) {
if (this.n > 0 && data[this.n - 1] == IntStream.EOF) {
if (this.n > 0 && data[this.n - 1] == (char)IntStream.EOF) {
return i;
}
@ -206,7 +206,7 @@ public class UnbufferedCharStream implements CharStream {
sync(i);
int index = p + i - 1;
if ( index < 0 ) throw new IndexOutOfBoundsException();
if ( index > n ) return IntStream.EOF;
if ( index >= n ) return IntStream.EOF;
char c = data[index];
if ( c==(char)IntStream.EOF ) return IntStream.EOF;
return c;
@ -315,7 +315,7 @@ public class UnbufferedCharStream implements CharStream {
if (interval.a < bufferStartIndex || interval.b >= bufferStartIndex + n) {
throw new UnsupportedOperationException("interval "+interval+" outside buffer: "+
bufferStartIndex+".."+(bufferStartIndex+n));
bufferStartIndex+".."+(bufferStartIndex+n-1));
}
// convert from absolute to local index
int i = interval.a - bufferStartIndex;