From 0aa65b868339d53eb31c77f3945ef90352565c2d Mon Sep 17 00:00:00 2001 From: hns Date: Fri, 29 Nov 2002 17:01:02 +0000 Subject: [PATCH] Add additional newline character at the end of every EcmaScript reader. Otherwise, a // comment in the last line throws a parsing error (bug 169) --- src/FESI/Parser/ASCII_CharStream.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/FESI/Parser/ASCII_CharStream.java b/src/FESI/Parser/ASCII_CharStream.java index 57fca334..5364b15e 100644 --- a/src/FESI/Parser/ASCII_CharStream.java +++ b/src/FESI/Parser/ASCII_CharStream.java @@ -13,6 +13,7 @@ public final class ASCII_CharStream int available; int tokenBegin; public int bufpos = -1; + boolean addedNewline = false; private int bufline[]; private int bufcolumn[]; @@ -107,8 +108,14 @@ public final class ASCII_CharStream if ((i = inputStream.read(buffer, maxNextCharInd, available - maxNextCharInd)) == -1) { - inputStream.close(); - throw new java.io.IOException(); + if (!addedNewline) { + addedNewline = true; + buffer[maxNextCharInd] = '\n'; + i = 1; + } else { + inputStream.close(); + throw new java.io.IOException(); + } } else maxNextCharInd += i; @@ -265,6 +272,7 @@ public final class ASCII_CharStream prevCharIsLF = prevCharIsCR = false; tokenBegin = inBuf = maxNextCharInd = 0; bufpos = -1; + addedNewline = false; } public void ReInit(java.io.Reader dstream, int startline, @@ -374,4 +382,4 @@ public final class ASCII_CharStream column = bufcolumn[j]; } -} \ No newline at end of file +}