summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2009-04-30 16:36:40 +0000
committerPaul Phillips <paulp@improving.org>2009-04-30 16:36:40 +0000
commit4d3c8ef4be9990124a02082789b809d8814b09ab (patch)
tree3acf70a100628a8954f2f665f7dbdea26810800f /src
parentb5b769354d8be94df5696dbb55c8ace4815f4170 (diff)
downloadscala-4d3c8ef4be9990124a02082789b809d8814b09ab.tar.gz
scala-4d3c8ef4be9990124a02082789b809d8814b09ab.tar.bz2
scala-4d3c8ef4be9990124a02082789b809d8814b09ab.zip
Two minor findbugs-discovered logic errors I've...
Two minor findbugs-discovered logic errors I've had in storage until I had xml write access.
Diffstat (limited to 'src')
-rw-r--r--src/library/scala/xml/PrettyPrinter.scala9
-rw-r--r--src/library/scala/xml/dtd/ElementValidator.scala2
2 files changed, 6 insertions, 5 deletions
diff --git a/src/library/scala/xml/PrettyPrinter.scala b/src/library/scala/xml/PrettyPrinter.scala
index 2b8c50088e..56e3a2db1b 100644
--- a/src/library/scala/xml/PrettyPrinter.scala
+++ b/src/library/scala/xml/PrettyPrinter.scala
@@ -153,6 +153,9 @@ class PrettyPrinter( width:Int, step:Int ) {
protected def fits(test: String) =
test.length < width - cur
+ private def doPreserve(node: Node) =
+ node.attribute(XML.namespace, XML.space).map(_.toString == XML.preserve) getOrElse false
+
/** @param tail: what we'd like to sqeeze in */
protected def traverse(node: Node, pscope: NamespaceBinding, ind: Int): Unit = node match {
@@ -166,10 +169,8 @@ class PrettyPrinter( width:Int, step:Int ) {
val test = {
val sb = new StringBuilder()
Utility.toXML(node, pscope, sb, false)
- if (node.attribute("http://www.w3.org/XML/1998/namespace", "space") == "preserve")
- sb.toString()
- else
- TextBuffer.fromString(sb.toString()).toText(0)._data
+ if (doPreserve(node)) sb.toString
+ else TextBuffer.fromString(sb.toString()).toText(0)._data
}
if (childrenAreLeaves(node) && fits(test)) {
makeBox(ind, test)
diff --git a/src/library/scala/xml/dtd/ElementValidator.scala b/src/library/scala/xml/dtd/ElementValidator.scala
index bbee01aa97..de969cab64 100644
--- a/src/library/scala/xml/dtd/ElementValidator.scala
+++ b/src/library/scala/xml/dtd/ElementValidator.scala
@@ -88,7 +88,7 @@ class ElementValidator() extends Function1[Node,Boolean] {
//Console.println("exc");
exc = fromUndefinedAttribute( attr.key ) :: exc;
- case AttrDecl(_, tpe, DEFAULT(true, fixedValue)) if(attr.value != fixedValue) =>
+ case AttrDecl(_, tpe, DEFAULT(true, fixedValue)) if attr.value.toString != fixedValue =>
exc = fromFixedAttribute( attr.key, fixedValue, attr.value.toString) :: exc;
case s =>