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:
parent
b93edfdc4d
commit
0aa65b8683
1 changed files with 11 additions and 3 deletions
|
@ -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,8 +108,14 @@ public final class ASCII_CharStream
|
||||||
if ((i = inputStream.read(buffer, maxNextCharInd,
|
if ((i = inputStream.read(buffer, maxNextCharInd,
|
||||||
available - maxNextCharInd)) == -1)
|
available - maxNextCharInd)) == -1)
|
||||||
{
|
{
|
||||||
inputStream.close();
|
if (!addedNewline) {
|
||||||
throw new java.io.IOException();
|
addedNewline = true;
|
||||||
|
buffer[maxNextCharInd] = '\n';
|
||||||
|
i = 1;
|
||||||
|
} else {
|
||||||
|
inputStream.close();
|
||||||
|
throw new java.io.IOException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
maxNextCharInd += i;
|
maxNextCharInd += i;
|
||||||
|
@ -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,
|
||||||
|
@ -374,4 +382,4 @@ public final class ASCII_CharStream
|
||||||
column = bufcolumn[j];
|
column = bufcolumn[j];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue