diff options
author | buraq <buraq@epfl.ch> | 2005-05-25 12:48:32 +0000 |
---|---|---|
committer | buraq <buraq@epfl.ch> | 2005-05-25 12:48:32 +0000 |
commit | 11f1938e73b7748e3d8ef1a532096d2a3a81c4dc (patch) | |
tree | d378871dbbee8f6927953d773ec808f5bb816e23 | |
parent | 8bdf158f08081c4d5c99b1247e204c8766565ebd (diff) | |
download | scala-11f1938e73b7748e3d8ef1a532096d2a3a81c4dc.tar.gz scala-11f1938e73b7748e3d8ef1a532096d2a3a81c4dc.tar.bz2 scala-11f1938e73b7748e3d8ef1a532096d2a3a81c4dc.zip |
correct handling of entity refs at end of file
-rw-r--r-- | sources/scala/xml/parsing/ConstructingParser.scala | 2 | ||||
-rw-r--r-- | sources/scala/xml/parsing/MarkupParser.scala | 41 |
2 files changed, 14 insertions, 29 deletions
diff --git a/sources/scala/xml/parsing/ConstructingParser.scala b/sources/scala/xml/parsing/ConstructingParser.scala index 7cf3bd6226..51299ec916 100644 --- a/sources/scala/xml/parsing/ConstructingParser.scala +++ b/sources/scala/xml/parsing/ConstructingParser.scala @@ -13,7 +13,6 @@ import scala.io.Source; object ConstructingParser { - def fromFile(inp: java.io.File, preserveWS: Boolean) = { /* DEBUG val src = Source.fromFile(inp); @@ -61,7 +60,6 @@ with MarkupParser { fileStr = inp.descr.substring(5, inp.descr.length()); } fileStr = fileStr.substring(0,fileStr.lastIndexOf(java.io.File.separator)+1); - Source.fromFile(fileStr + systemLiteral); } } diff --git a/sources/scala/xml/parsing/MarkupParser.scala b/sources/scala/xml/parsing/MarkupParser.scala index 53b9e9e6a4..8b52bd8db4 100644 --- a/sources/scala/xml/parsing/MarkupParser.scala +++ b/sources/scala/xml/parsing/MarkupParser.scala @@ -44,8 +44,6 @@ abstract class MarkupParser: (MarkupParser with MarkupHandler) extends AnyRef wi /** holds the position in the source file */ var pos: Int = _; - /* true if reading external sources */ - var isReadingExternal = false;; /* true if reading external subset */ var inExtSubSet = false; @@ -229,10 +227,9 @@ abstract class MarkupParser: (MarkupParser with MarkupHandler) extends AnyRef wi pos = curInput.pos; } else { //Console.println("nextch, curInput.hasNext == false ") ; - //Console.println("nextch, isReadingExternal == "+isReadingExternal); //Console.println("nextch, Nil != inpStack == "+(Nil!=inpStack)); - if ((!isReadingExternal) && (Nil != inpStack)) { - /** for external source, we like to be notified of eof! */ + if (Nil != inpStack) { + /** for external source, inpStack == Nil ! need notify of eof! */ pop(); } else { eof = true; @@ -585,7 +582,6 @@ abstract class MarkupParser: (MarkupParser with MarkupHandler) extends AnyRef wi if(null != extID) { val extSubsetSrc = externalSource( extID.systemId ); - isReadingExternal = true; inExtSubSet = true; /* .indexOf(':') != -1) { // assume URI @@ -603,7 +599,6 @@ abstract class MarkupParser: (MarkupParser with MarkupHandler) extends AnyRef wi nextch; extSubset(); - isReadingExternal = false; inExtSubSet = false; curInput = old; @@ -873,10 +868,10 @@ abstract class MarkupParser: (MarkupParser with MarkupHandler) extends AnyRef wi //Console.println("how can we be eof = "+eof); // eof = true because not external?! - if(!eof) - error("expected only INCLUDE or IGNORE"); + //if(!eof) + // error("expected only INCLUDE or IGNORE"); - pop(); + //pop(); //Console.println("hello, popped"); @@ -914,20 +909,15 @@ abstract class MarkupParser: (MarkupParser with MarkupHandler) extends AnyRef wi } def markupDecl(): Unit = ch match { - /** parameter entity reference - * n-v: just create PE-reference - * v: "parse replacementText into NodeBuffer ?" - */ - case '%' => + case '%' => // parameter entity reference nextch; val ent = xName; xToken(';'); if(!isValidating) - handle.peReference(ent); - else { - //Console.println("pushed entity "+ent); - push(ent); - } + handle.peReference(ent); // n-v: just create PE-reference + else + push(ent); // v: parse replacementText + //peReference case '<' => nextch; @@ -936,7 +926,6 @@ abstract class MarkupParser: (MarkupParser with MarkupHandler) extends AnyRef wi case _ if isSpace(ch) => xSpace; case _ => - //Console.println("still think am reading external: "+isReadingExternal); reportSyntaxError("markupdecl: unexpected character '"+ch+"'"); nextch; } @@ -1114,7 +1103,9 @@ abstract class MarkupParser: (MarkupParser with MarkupHandler) extends AnyRef wi //Console.println("BEFORE PUSHING "+ch); //Console.println("BEFORE PUSHING "+pos); //Console.println("PUSHING "+entityName); - inpStack = curInput :: inpStack; + if(!eof) { + inpStack = curInput :: inpStack; + } curInput = replacementText(entityName); nextch; } @@ -1131,11 +1122,7 @@ abstract class MarkupParser: (MarkupParser with MarkupHandler) extends AnyRef wi inpStack = inpStack.tail; ch = curInput.ch; pos = curInput.pos; - eof = !curInput.hasNext; - //Console.println("returned (popped), current ch = "+ch ) - //Console.println("POPPING ch now "+ch); - //Console.println("POPPING ch now "+pos); - //nextch; + eof = false; // must be false, because of places where entity refs occur } } |