summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAleksandar Pokopec <aleksandar.prokopec@epfl.ch>2011-02-22 16:30:37 +0000
committerAleksandar Pokopec <aleksandar.prokopec@epfl.ch>2011-02-22 16:30:37 +0000
commitc9f6d655362863afe66458f91f556905b8002ed5 (patch)
tree3796955b74a811a24c983ef1d4d466e2ef5b0dd6 /src
parent1236b5d14b26acee0edd06c78180e151a56fb2ac (diff)
downloadscala-c9f6d655362863afe66458f91f556905b8002ed5.tar.gz
scala-c9f6d655362863afe66458f91f556905b8002ed5.tar.bz2
scala-c9f6d655362863afe66458f91f556905b8002ed5.zip
Fixes and closes #4261.
No review.
Diffstat (limited to 'src')
-rw-r--r--src/library/scala/xml/Utility.scala8
-rw-r--r--src/library/scala/xml/parsing/MarkupParserCommon.scala9
2 files changed, 9 insertions, 8 deletions
diff --git a/src/library/scala/xml/Utility.scala b/src/library/scala/xml/Utility.scala
index 2d0682a47d..995563e9ac 100644
--- a/src/library/scala/xml/Utility.scala
+++ b/src/library/scala/xml/Utility.scala
@@ -22,6 +22,8 @@ import parsing.XhtmlEntities
*/
object Utility extends AnyRef with parsing.TokenTests
{
+ final val SU = '\u001A'
+
implicit def implicitSbToString(sb: StringBuilder) = sb.toString()
// helper for the extremely oft-repeated sequence of creating a
@@ -360,7 +362,7 @@ object Utility extends AnyRef with parsing.TokenTests
c = it.next
if (c == '#') {
c = it.next
- val theChar = parseCharRef ({ ()=> c },{ () => c = it.next },{s => throw new RuntimeException(s)})
+ val theChar = parseCharRef ({ ()=> c },{ () => c = it.next },{s => throw new RuntimeException(s)}, {s => throw new RuntimeException(s)})
sb.append(theChar)
}
else {
@@ -410,7 +412,7 @@ object Utility extends AnyRef with parsing.TokenTests
* @param reportSyntaxError ...
* @return ...
*/
- def parseCharRef(ch: () => Char, nextch: () => Unit, reportSyntaxError: String => Unit): String = {
+ def parseCharRef(ch: () => Char, nextch: () => Unit, reportSyntaxError: String => Unit, reportTruncatedError: String => Unit): String = {
val hex = (ch() == 'x') && { nextch(); true }
val base = if (hex) 16 else 10
var i = 0
@@ -425,6 +427,8 @@ object Utility extends AnyRef with parsing.TokenTests
"Did you mean to write &#x ?")
else
i = i * base + ch().asDigit
+ case SU =>
+ reportTruncatedError("")
case _ =>
reportSyntaxError("character '" + ch() + "' not allowed in char ref\n")
}
diff --git a/src/library/scala/xml/parsing/MarkupParserCommon.scala b/src/library/scala/xml/parsing/MarkupParserCommon.scala
index b11c908bc2..d2174c2879 100644
--- a/src/library/scala/xml/parsing/MarkupParserCommon.scala
+++ b/src/library/scala/xml/parsing/MarkupParserCommon.scala
@@ -14,10 +14,7 @@ import scala.xml.dtd._
import scala.annotation.switch
import Utility.Escapes.{ pairs => unescape }
-object MarkupParserCommon {
- final val SU = '\u001A'
-}
-import MarkupParserCommon._
+import Utility.SU
/** This is not a public trait - it contains common code shared
* between the library level XML parser and the compiler's.
@@ -158,11 +155,11 @@ private[scala] trait MarkupParserCommon extends TokenTests {
* see [66]
*/
def xCharRef(ch: () => Char, nextch: () => Unit): String =
- Utility.parseCharRef(ch, nextch, reportSyntaxError _)
+ Utility.parseCharRef(ch, nextch, reportSyntaxError _, truncatedError _)
def xCharRef(it: Iterator[Char]): String = {
var c = it.next
- Utility.parseCharRef(() => c, () => { c = it.next }, reportSyntaxError _)
+ Utility.parseCharRef(() => c, () => { c = it.next }, reportSyntaxError _, truncatedError _)
}
def xCharRef: String = xCharRef(() => ch, () => nextch)