Add additional newline character at the end of every EcmaScript reader.

Otherwise, a // comment in the last line throws a parsing error (bug 169)
This commit is contained in:
hns 2002-11-29 17:01:02 +00:00
parent b93edfdc4d
commit 0aa65b8683

View file

@ -13,6 +13,7 @@ public final class ASCII_CharStream
int available; int available;
int tokenBegin; int tokenBegin;
public int bufpos = -1; public int bufpos = -1;
boolean addedNewline = false;
private int bufline[]; private int bufline[];
private int bufcolumn[]; private int bufcolumn[];
@ -107,9 +108,15 @@ public final class ASCII_CharStream
if ((i = inputStream.read(buffer, maxNextCharInd, if ((i = inputStream.read(buffer, maxNextCharInd,
available - maxNextCharInd)) == -1) available - maxNextCharInd)) == -1)
{ {
if (!addedNewline) {
addedNewline = true;
buffer[maxNextCharInd] = '\n';
i = 1;
} else {
inputStream.close(); inputStream.close();
throw new java.io.IOException(); throw new java.io.IOException();
} }
}
else else
maxNextCharInd += i; maxNextCharInd += i;
return; return;
@ -265,6 +272,7 @@ public final class ASCII_CharStream
prevCharIsLF = prevCharIsCR = false; prevCharIsLF = prevCharIsCR = false;
tokenBegin = inBuf = maxNextCharInd = 0; tokenBegin = inBuf = maxNextCharInd = 0;
bufpos = -1; bufpos = -1;
addedNewline = false;
} }
public void ReInit(java.io.Reader dstream, int startline, public void ReInit(java.io.Reader dstream, int startline,