From e29a183a6455eff17182e4b6fc3acfdfb3f10624 Mon Sep 17 00:00:00 2001 From: michelou Date: Wed, 12 Apr 2006 16:55:00 +0000 Subject: added options '-windowtitle' and '-documenttitl... added options '-windowtitle' and '-documenttitle' to command scaladoc added attributes 'windowtitle' and 'documenttitle' to Ant task 'Scaladoc' added option '-encoding iso-8859-1' in script test/scalatest removed leading tabs in scala/xml/*.scala --- build.xml | 6 +- src/compiler/scala/tools/ant/Scaladoc.scala | 39 ++++++-- src/compiler/scala/tools/nsc/Main.scala | 10 +- src/compiler/scala/tools/nsc/Settings.scala | 6 +- .../scala/tools/nsc/doc/DocGenerator.scala | 92 ++++++++++-------- src/compiler/scala/tools/nsc/doc/DocUtil.scala | 12 ++- src/library/scala/xml/Text.scala | 20 ++-- src/library/scala/xml/Utility.scala | 106 ++++++++++----------- test/scalatest | 14 +-- 9 files changed, 176 insertions(+), 129 deletions(-) diff --git a/build.xml b/build.xml index 72df20510a..da4c6e5343 100644 --- a/build.xml +++ b/build.xml @@ -925,6 +925,8 @@ DOCUMENTATION srcdir="${src.dir}" destdir="${api.lib.dir}" sourcepath="" + windowtitle="Scala Library Documentation" + documenttitle="<div>Scala 2<div>${version.number}</div></div>" > @@ -934,7 +936,7 @@ DOCUMENTATION - + diff --git a/src/compiler/scala/tools/ant/Scaladoc.scala b/src/compiler/scala/tools/ant/Scaladoc.scala index d23eca04ba..a87f72ac3f 100644 --- a/src/compiler/scala/tools/ant/Scaladoc.scala +++ b/src/compiler/scala/tools/ant/Scaladoc.scala @@ -2,10 +2,11 @@ ** / |/ / ____/ ____/ ** ** / | | /___ / /___ ** ** /_/|__/_____/_____/ Copyright 2005-2006 LAMP/EPFL ** -** -** $Id$ +** ** \* */ +// $Id$ + package scala.tools.ant { @@ -38,7 +39,9 @@ package scala.tools.ant { *
  • bootclasspathref,
  • *
  • extdirs,
  • *
  • extdirsref,
  • - *
  • encoding.
  • + *
  • encoding,
  • + *
  • windowtitle,
  • + *
  • documenttitle.
  • * * It also takes the following parameters as nested elements:
      *
    • src (for srcdir),
    • @@ -48,7 +51,8 @@ package scala.tools.ant { *
    • extdirs.
    • *
    * - * @author Gilles Dubochet */ + * @author Gilles Dubochet, Stephane Micheloud + */ class Scaladoc extends MatchingTask { /** The unique Ant file utilities instance to use in this task. */ @@ -75,6 +79,11 @@ package scala.tools.ant { /** The character encoding of the files to compile. */ private var encoding: Option[String] = None + /** The window title of the generated HTML documentation. */ + private var windowtitle: Option[String] = None + /** The document title of the generated HTML documentation. */ + private var documenttitle: Option[String] = None + /******************************************************************************\ ** Properties setters ** \******************************************************************************/ @@ -176,11 +185,21 @@ package scala.tools.ant { def setExtdirsref(input: Reference) = createExtdirs().setRefid(input) - /** Sets the encoding attribute. Used by Ant. + /** Sets the encoding attribute. Used by Ant. * @param input The value of encoding. */ def setEncoding(input: String): Unit = encoding = Some(input) + /** Sets the windowtitle attribute. + * @param input The value of windowtitle. */ + def setWindowtitle(input: String): Unit = + windowtitle = Some(input) + + /** Sets the documenttitle attribute. + * @param input The value of documenttitle. */ + def setDocumenttitle(input: String): Unit = + documenttitle = Some(input) + /******************************************************************************\ ** Properties getters ** \******************************************************************************/ @@ -189,8 +208,7 @@ package scala.tools.ant { * @returns The class path as a list of files. */ private def getClasspath: List[File] = if (classpath.isEmpty) error("Member 'classpath' is empty.") - else - List.fromArray(classpath.get.list()).map(nameToFile) + else List.fromArray(classpath.get.list()).map(nameToFile) /** Gets the value of the origin attribute in a Scala-friendly form. * @returns The origin path as a list of files. */ @@ -312,7 +330,6 @@ package scala.tools.ant { /** Performs the compilation. */ override def execute() = { - // Tests if all mandatory attributes are set and valid. if (origin.isEmpty) error("Attribute 'srcdir' is not set.") if (getOrigin.isEmpty) error("Attribute 'srcdir' is not set.") @@ -366,15 +383,19 @@ package scala.tools.ant { settings.bootclasspath.value = asString(getBootclasspath) if (!extdirs.isEmpty) settings.extdirs.value = asString(getExtdirs) if (!encoding.isEmpty) settings.encoding.value = encoding.get + if (!windowtitle.isEmpty) settings.windowtitle.value = windowtitle.get + if (!documenttitle.isEmpty) settings.documenttitle.value = documenttitle.get // Compiles the actual code object compiler extends Global(settings, reporter) try { val run = new compiler.Run - run.compile(sourceFiles.map(f:File=>f.toString())) + run.compile(sourceFiles.map(f: File => f.toString())) object generator extends DocGenerator { val global = compiler val outdir = settings.outdir.value + val windowTitle = settings.windowtitle.value + val documentTitle = settings.documenttitle.value } generator.process(run.units) if (reporter.errors > 0) diff --git a/src/compiler/scala/tools/nsc/Main.scala b/src/compiler/scala/tools/nsc/Main.scala index b69ef5cbe6..bd6498fca9 100644 --- a/src/compiler/scala/tools/nsc/Main.scala +++ b/src/compiler/scala/tools/nsc/Main.scala @@ -16,9 +16,9 @@ import scala.tools.nsc.doc.DocGenerator object Main extends Object with EvalLoop { val PRODUCT: String = - System.getProperty("scala.product", "scalac") + System.getProperty("scala.tool.name", "scalac") val VERSION: String = - System.getProperty("scala.version", "unknown version") + System.getProperty("scala.tool.version", "unknown version") val COPYRIGHT: String = System.getProperty("scala.copyright", "(c) 2002-2006 LAMP/EPFL") val versionMsg = PRODUCT + " " + VERSION + " -- " + COPYRIGHT @@ -60,8 +60,10 @@ object Main extends Object with EvalLoop { run compile command.files if (command.settings.doc.value) { object generator extends DocGenerator { - val global : compiler.type = compiler; - val outdir = command.settings.outdir.value; + val global : compiler.type = compiler + val outdir = command.settings.outdir.value + val windowTitle = command.settings.windowtitle.value + val documentTitle = command.settings.documenttitle.value }; generator.process(run.units) } diff --git a/src/compiler/scala/tools/nsc/Settings.scala b/src/compiler/scala/tools/nsc/Settings.scala index ab14e2e473..8b7989bb09 100644 --- a/src/compiler/scala/tools/nsc/Settings.scala +++ b/src/compiler/scala/tools/nsc/Settings.scala @@ -24,7 +24,6 @@ class Settings(error: String => unit) { ".") else getProperty("java.class.path") - private val bootclasspathDefault = alternatePath( concatPath( @@ -61,6 +60,9 @@ class Settings(error: String => unit) { new java.io.OutputStreamWriter( new java.io.ByteArrayOutputStream()).getEncoding + private val windowtitleDefault = "Scala Library Documentation" + private val documenttitleDefault = "Scala 2" + val doc = BooleanSetting("-doc", "Generate documentation"); val debuginfo = BooleanSetting("-g", "Generate debugging info") val nowarnings = BooleanSetting("-nowarn", "Generate no warnings") @@ -74,6 +76,8 @@ class Settings(error: String => unit) { val extdirs = StringSetting ("-extdirs", "dirs", "Override location of installed extensions", extdirsDefault) val outdir = StringSetting ("-d", "directory", "Specify where to place generated class files", ".") val encoding = StringSetting ("-encoding", "encoding", "Specify character encoding used by source files", encodingDefault) + val windowtitle = StringSetting ("-windowtitle", "windowtitle", "Specify window title of generated HTML documentation", windowtitleDefault) + val documenttitle = StringSetting ("-documenttitle", "documenttitle", "Specify document title of generated HTML documentation", documenttitleDefault) val target = ChoiceSetting ("-target", "Specify which backend to use", List("jvm", "msil"), "jvm") val migrate = BooleanSetting("-migrate", "Assist in migrating from Scala version 1.0") val debug = BooleanSetting("-debug", "Output debugging messages") diff --git a/src/compiler/scala/tools/nsc/doc/DocGenerator.scala b/src/compiler/scala/tools/nsc/doc/DocGenerator.scala index 3fbfd3f942..55278d44ea 100644 --- a/src/compiler/scala/tools/nsc/doc/DocGenerator.scala +++ b/src/compiler/scala/tools/nsc/doc/DocGenerator.scala @@ -17,24 +17,26 @@ abstract class DocGenerator extends Models { import global._ import DocUtil._ def outdir: String + def windowTitle: String + def documentTitle: String def contentFrame = "contentFrame" def classesFrame = "classesFrame" def modulesFrame = "modulesFrame" - def emptyMap = ListMap.Empty[Kind,TreeSet[HasTree]]; + def emptyMap = ListMap.Empty[Kind,TreeSet[HasTree]] override def acceptPrivate = false; abstract class Frame extends UrlContext { def path: String; // relative to outdir def relative: String = { - assert(path != null); - var idx = 0; - var ct = ""; + assert(path != null) + var idx = 0 + var ct = "" while (idx != -1) { idx = path.indexOf('/', idx); //System.err.println(path + " idx=" + idx); ct = ct + (if (idx != -1) "../" else ""); - idx = idx + (if (idx == -1) 0 else 1); + idx = idx + (if (idx == -1) 0 else 1) } ct } @@ -54,7 +56,7 @@ abstract class DocGenerator extends Models { writer.close() } - def urlFor(sym : Symbol, target : String) : NodeSeq = try { + def urlFor(sym: Symbol, target: String): NodeSeq = try { if (sym.sourceFile == null) Text(sym.fullNameString('.')); else aref(urlFor(sym), target, sym.nameString); } catch { @@ -72,7 +74,7 @@ abstract class DocGenerator extends Models { Text(tpe.symbol.toString()) } - def urlFor0(sym : Symbol, orig : Symbol) : String = { + def urlFor0(sym: Symbol, orig: Symbol): String = { (if (sym == NoSymbol) { "XXX"; } else if (sym.owner.isPackageClass) sym.fullNameString('/'); @@ -104,12 +106,17 @@ abstract class DocGenerator extends Models { save(page(title, body, hasBody)) } + val doctitle: NodeSeq = +
    + {load(documentTitle)} +
    ; + abstract class ListModuleFrame extends Frame { val path = "modules"; val title = "List of all packages"; def modules : TreeMap[String,ModuleClassSymbol]; def body : NodeSeq = { - val x = div0("Scala 2") concat + val x = doctitle concat aref("all-classes.html", classesFrame, "All objects and classes"); val y =

    Packages ; } - def fullComment(mmbr : HasTree) : NodeSeq = { + def fullComment(mmbr: HasTree): NodeSeq = { if (comments.contains(mmbr.tree.symbol)) comment(comments(mmbr.tree.symbol), false) else NodeSeq.Empty; }; - def shortComment(mmbr : HasTree) : NodeSeq = { + def shortComment(mmbr: HasTree): NodeSeq = { if (comments.contains(mmbr.tree.symbol)) comment(comments(mmbr.tree.symbol), true) else NodeSeq.Empty; }; - def ifT (cond : Boolean, nodes : NodeSeq) = if (cond) nodes else NodeSeq.Empty; + def ifT (cond: Boolean, nodes: NodeSeq) = if (cond) nodes else NodeSeq.Empty; def ifT (tree : Tree, nodes : NodeSeq, before : Boolean) = { if (tree != EmptyTree && tree.tpe.symbol != definitions.AnyClass && @@ -295,7 +302,7 @@ abstract class DocGenerator extends Models { def forType(tpe: Type): NodeSeq = urlFor(tpe, contentFrame); - def forTree(tree : Tree) : NodeSeq = tree match { + def forTree(tree: Tree): NodeSeq = tree match { case vdef : ValDef => Text(vdef.symbol.name.toString()).concat(Text(" : ")).concat(forTree(vdef.tpt)); case sel : Select => forTree(sel.qualifier).concat(Text(sel.symbol.nameString)); @@ -319,17 +326,17 @@ abstract class DocGenerator extends Models { def surround(open: String, close: String, node: NodeSeq): NodeSeq = Text(open).concat(node).concat(Text(close)); - def typesFor(ht : HasTree) : NodeSeq = { + def typesFor(ht: HasTree): NodeSeq = { val tparams = ht.tree match { - case cdef : ClassDef => cdef.tparams; - case ddef : DefDef => ddef.tparams; - case adef : AliasTypeDef => adef.tparams; - case _ => Nil; + case cdef: ClassDef => cdef.tparams + case ddef: DefDef => ddef.tparams + case adef: AliasTypeDef => adef.tparams + case _ => Nil } if (tparams.isEmpty) Text(""); else surround("[", "]", forTrees(tparams)); } - def argsFor(ht : HasTree) : NodeSeq = ht.tree match { + def argsFor(ht: HasTree): NodeSeq = ht.tree match { case ddef : DefDef => if (!ddef.vparamss.isEmpty && (!ddef.vparamss.tail.isEmpty || !ddef.vparamss.head.isEmpty)) { @@ -339,12 +346,13 @@ abstract class DocGenerator extends Models { } else NodeSeq.Empty; case _ => NodeSeq.Empty; } - def resultFor(ht : HasTree) : NodeSeq = ht.tree match { + def resultFor(ht: HasTree): NodeSeq = ht.tree match { case vdef : ValOrDefDef => if (!vdef.symbol.nameString.equals("this")) Text(" : ").concat(forTree(vdef.tpt)); else NodeSeq.Empty; - case _ => NodeSeq.Empty; + case _ => + NodeSeq.Empty } } @@ -355,7 +363,7 @@ abstract class DocGenerator extends Models { def path = module.fullNameString('/') + "$content"; def title = "All Classes and Objects in " + module.fullNameString('.'); - def body : NodeSeq = { + def body: NodeSeq = {
    Scala 2
    API Specification @@ -378,8 +386,8 @@ abstract class DocGenerator extends Models { } abstract class ContentFrame extends ContentFrame0 { - def clazz: ImplMod; - def kind: Kind; + def clazz: ImplMod + def kind: Kind def body: NodeSeq = {navigation}{header0}{fullHeader(clazz)}; final def path = urlFor0(clazz.tree.symbol,clazz.tree.symbol); @@ -387,7 +395,7 @@ abstract class DocGenerator extends Models { //
    // // - def navigation : NodeSeq = + def navigation: NodeSeq =
    @@ -150,15 +157,15 @@ abstract class DocGenerator extends Models { } abstract class ListClassFrame extends Frame { - def classes: ListMap[Kind,TreeSet[HasTree]]; + def classes: ListMap[Kind,TreeSet[HasTree]] - def navLabel: String; + def navLabel: String private def path0 = { - val p = path; + val p = path if (p.endsWith("$package")) - p.substring(0, p.length() - ("$package").length()); - else p; + p.substring(0, p.length() - ("$package").length()) + else p } def body : NodeSeq = { @@ -254,7 +261,7 @@ abstract class DocGenerator extends Models { } } ; } else NodeSeq.Empty; - def shortHeader(mmbr : HasTree) : NodeSeq = { + def shortHeader(mmbr: HasTree): NodeSeq = {
    { { for (val str <- stringsFor(mmbr.mods)) yield {(Text(str + " "))}; } } @@ -270,15 +277,15 @@ abstract class DocGenerator extends Models {
    - {div0("Scala 2")} + {doctitle} ; - def header0 : NodeSeq = + def header0: NodeSeq =


    in {aref(urlFor(clazz.tree.symbol.owner), "_self", clazz.tree.symbol.owner.fullNameString('.'))}
    {Text(codeFor(kind))} @@ -454,8 +462,8 @@ abstract class DocGenerator extends Models { // class from for each module. for (val top <- topLevel.elements) { - val module = top._1; - val members = top._2; + val module = top._1 + val members = top._2 new ListClassFrame { def title = "List of classes and objects in package " + module.fullNameString('.') @@ -482,10 +490,10 @@ abstract class DocGenerator extends Models { } new Frame { - def title = "Scala Library Documentation"; - def body = index; - def path = "index"; - override def hasBody = false; + def title = windowTitle + def body = index + def path = "index" + override def hasBody = false }; for (val base <- "style.css" :: "script.js" :: Nil) { val input = getClass().getClassLoader().getResourceAsStream("scala/tools/nsc/doc/" + base); @@ -503,7 +511,7 @@ abstract class DocGenerator extends Models { } } input.close(); - output.close(); + output.close() } } } @@ -528,10 +536,10 @@ abstract class DocGenerator extends Models { def parse(str : String) : NodeSeq = { new SpecialNode { - def label = "#PCDATA"; - def toString(sb:StringBuffer): StringBuffer = { + def label = "#PCDATA" + def toString(sb: StringBuffer): StringBuffer = { sb.append(str.trim()); - sb; + sb } } diff --git a/src/compiler/scala/tools/nsc/doc/DocUtil.scala b/src/compiler/scala/tools/nsc/doc/DocUtil.scala index f98bd5e6ad..d187c7d182 100644 --- a/src/compiler/scala/tools/nsc/doc/DocUtil.scala +++ b/src/compiler/scala/tools/nsc/doc/DocUtil.scala @@ -2,10 +2,13 @@ * Copyright 2005-2006 LAMP/EPFL * @author Sean McDirmid */ -// $Id: $ +// $Id$ package scala.tools.nsc.doc +import java.io.StringReader +import org.xml.sax.InputSource + import scala.collection.immutable._ import scala.xml._ @@ -14,6 +17,13 @@ object DocUtil { def dquote(str: String): NodeSeq = DQUOTE :: Text(str) :: DQUOTE :: Nil + def load(str: String): NodeSeq = { + val xmlStr = str.replaceAll("<", "<").replaceAll(">",">") + .replaceAll("&", "&").replaceAll(""", "\"") + val xmlSrc = new InputSource(new StringReader(xmlStr)) + XML.load(xmlSrc) + } + object DQUOTE extends SpecialNode { def toString(sb: StringBuffer) = { sb.append("\""); sb diff --git a/src/library/scala/xml/Text.scala b/src/library/scala/xml/Text.scala index 6bb0019177..8f612f28e5 100644 --- a/src/library/scala/xml/Text.scala +++ b/src/library/scala/xml/Text.scala @@ -9,7 +9,7 @@ // $Id$ -package scala.xml; +package scala.xml /** an XML node for text (PCDATA). Used in both non-bound and bound XML @@ -17,19 +17,19 @@ package scala.xml; * @author Burak Emir * @param text the text contained in this node, may not be null. */ -case class Text( _data: String ) extends Atom[String](_data) { +case class Text(_data: String) extends Atom[String](_data) { - if(null == data) - throw new java.lang.NullPointerException("tried to construct Text with null"); + if (null == data) + throw new java.lang.NullPointerException("tried to construct Text with null") - final override def equals(x:Any) = x match { - case s:String => s.equals( data.toString() ); - case s:Text => data == s.data ; - case _ => false; + final override def equals(x: Any) = x match { + case s:String => s.equals(data.toString()) + case s:Text => data == s.data + case _ => false } /** returns text, with some characters escaped according to XML spec */ - override def toString(sb:StringBuffer) = - Utility.escape( data.toString(), sb ); + override def toString(sb: StringBuffer) = + Utility.escape(data.toString(), sb) } diff --git a/src/library/scala/xml/Utility.scala b/src/library/scala/xml/Utility.scala index 618f39e568..f1e5eb3bc5 100644 --- a/src/library/scala/xml/Utility.scala +++ b/src/library/scala/xml/Utility.scala @@ -9,33 +9,32 @@ // $Id$ -package scala.xml; +package scala.xml -import java.lang.StringBuffer; -import scala.collection.mutable; +import java.lang.StringBuffer +import scala.collection.mutable /** - * Utility functions for processing instances of bound and not bound XML - * classes, as well as escaping text nodes + * Utility functions for processing instances of bound and + * not bound XML classes, as well as escaping text nodes. */ object Utility extends AnyRef with parsing.TokenTests { - def view(s: String): Text = Text(s); + def view(s: String): Text = Text(s) /* escapes the characters < > & and " from string */ final def escape(text: String): String = - escape(text, new StringBuffer()).toString(); - + escape(text, new StringBuffer()).toString() /* appends escaped string to s */ final def escape(text: String, s: StringBuffer): StringBuffer = { for (val c <- Iterator.fromString(text)) c match { - case '<' => s.append("<"); - case '>' => s.append(">"); - case '&' => s.append("&"); - case '"' => s.append("""); - case _ => s.append(c); + case '<' => s.append("<") + case '>' => s.append(">") + case '&' => s.append("&") + case '"' => s.append(""") + case _ => s.append(c) } s } @@ -48,8 +47,8 @@ object Utility extends AnyRef with parsing.TokenTests { */ def collectNamespaces(nodes: Seq[Node]): mutable.Set[String] = { - var m = new mutable.HashSet[String](); - val it = nodes.elements; + var m = new mutable.HashSet[String]() + val it = nodes.elements while (it.hasNext) collectNamespaces(it.next, m); m @@ -84,9 +83,9 @@ object Utility extends AnyRef with parsing.TokenTests { * @todo define a way to escape literal characters to &xx; references */ def toXML(n: Node, stripComment: Boolean): String = { - val sb = new StringBuffer(); - toXML(n, TopScope, sb, stripComment); - sb.toString(); + val sb = new StringBuffer() + toXML(n, TopScope, sb, stripComment) + sb.toString() } @@ -101,34 +100,33 @@ object Utility extends AnyRef with parsing.TokenTests { x match { case c: Comment if !stripComment => - c.toString(sb) + c.toString(sb) case x: SpecialNode => - x.toString(sb) + x.toString(sb) case _ => // print tag with namespace declarations - sb.append('<'); - x.nameToString(sb); + sb.append('<') + x.nameToString(sb) if (x.attributes != null) { x.attributes.toString(sb) } - x.scope.toString(sb, pscope); - sb.append('>'); + x.scope.toString(sb, pscope) + sb.append('>') for (val c <- x.child.elements) { - toXML(c, x.scope, sb, stripComment); + toXML(c, x.scope, sb, stripComment) } - sb.append("') - } } /** returns prefix of qualified name if any */ final def prefix(name: String): Option[String] = { - val i = name.indexOf(':'.asInstanceOf[Int]); + val i = name.indexOf(':'.asInstanceOf[Int]) if( i != -1 ) Some( name.substring(0, i) ) else None } @@ -161,21 +159,21 @@ object Utility extends AnyRef with parsing.TokenTests { */ def systemLiteralToString(s: String): String = { - val sb = new StringBuffer(); - systemLiteralToString(sb, s); - sb.toString(); - } + val sb = new StringBuffer() + systemLiteralToString(sb, s) + sb.toString() + } def systemLiteralToString(sb: StringBuffer, s: String): StringBuffer = { - sb.append("SYSTEM "); - appendQuoted(s, sb); + sb.append("SYSTEM ") + appendQuoted(s, sb) } def publicLiteralToString(s: String): String = { - val sb = new StringBuffer(); - systemLiteralToString(sb, s); - sb.toString(); - } + val sb = new StringBuffer() + systemLiteralToString(sb, s) + sb.toString() + } def publicLiteralToString(sb: StringBuffer, s: String): StringBuffer = { sb.append("PUBLIC \"").append(s).append('"') @@ -200,11 +198,11 @@ object Utility extends AnyRef with parsing.TokenTests { * @param sb */ def appendEscapedQuoted(s: String, sb: StringBuffer) = { - sb.append('"'); - val z:Seq[Char] = Predef.string2seq(s); + sb.append('"') + val z:Seq[Char] = Predef.string2seq(s) for( val c <- z ) c match { - case '"' => sb.append('\\'); sb.append('"'); - case _ => sb.append( c ); + case '"' => sb.append('\\'); sb.append('"') + case _ => sb.append(c) } sb.append('"') } @@ -212,36 +210,36 @@ object Utility extends AnyRef with parsing.TokenTests { def getName(s: String, index: Int): String = { var i = index; val sb = new StringBuffer(); - if(i < s.length()) { + if (i < s.length()) { var c = s.charAt(i); - if(isNameStart(s.charAt(i))) - while(i < s.length() && { c = s.charAt(i); isNameChar(c)}) { + if (isNameStart(s.charAt(i))) + while (i < s.length() && { c = s.charAt(i); isNameChar(c)}) { sb.append(c); - i = i + 1; + i = i + 1 } - sb.toString(); + sb.toString() } else null } /** returns null if the value is a correct attribute value, error message if it isn't */ def checkAttributeValue(value: String): String = { - var i = 0; - while(i < value.length()) { + var i = 0 + while (i < value.length()) { value.charAt(i) match { case '<' => return "< not allowed in attribute value"; case '&' => val n = getName(value, i+1); - if(n== null) + if (n== null) return "malformed entity reference in attribute value ["+value+"]"; i = i + n.length() + 1; - if(i >= value.length() || value.charAt(i) != ';') + if (i >= value.length() || value.charAt(i) != ';') return "malformed entity reference in attribute value ["+value+"]"; case _ => } - i = i + 1; + i = i + 1 } - return null; + null } } diff --git a/test/scalatest b/test/scalatest index a5bd6a3547..faa9a97c87 100755 --- a/test/scalatest +++ b/test/scalatest @@ -203,7 +203,7 @@ test_print_failure() { test_run_pos() { rm -rf "$dstbase".obj && mkdir -p "$dstbase".obj && - $SOCOS -d "$os_dstbase".obj "$@" "$os_srcbase".scala && + $SCALAC -d "$os_dstbase".obj "$@" "$os_srcbase".scala && rm -rf "$dstbase".obj; } @@ -211,7 +211,7 @@ test_run_pos() { test_run_neg() { rm -rf "$dstbase".obj && mkdir -p "$dstbase".obj && - ( cd "$srcdir" && $SOCOS -d "$os_dstbase".obj "$@" "$testname".scala; ); + ( cd "$srcdir" && $SCALAC -d "$os_dstbase".obj "$@" "$testname".scala; ); if [ "$?" = 0 ]; then status=1; else status=0; fi; rm -rf "$dstbase".obj; return $status; @@ -221,7 +221,7 @@ test_run_neg() { test_run_jvm() { rm -rf "$dstbase".obj && mkdir -p "$dstbase".obj && - $SOCOS -d "$os_dstbase".obj "$@" "$os_srcbase".scala && + $SCALAC -d "$os_dstbase".obj "$@" "$os_srcbase".scala && classpath=`get_os_pathlist "$os_dstbase".obj:$CLASSPATH` && $SCALA -classpath $classpath Test "jvm" && rm -rf "$dstbase".obj; @@ -235,7 +235,7 @@ test_run_dis() { fi; rm -rf "$dstbase".obj && mkdir -p "$dstbase".obj && - $SOCOS -d "$os_dstbase".obj "$@" "$os_srcbase".scala && + $SCALAC -d "$os_dstbase".obj "$@" "$os_srcbase".scala && $SCALAP -classpath "$os_dstbase".obj `cat "$argsfile"` && rm -rf "$dstbase".obj; } @@ -245,7 +245,7 @@ test_run_msil() { assemblies=`get_os_pathlist "/home/linuxsoft/apps/msil"`; rm -f "$dstbase".il && rm -f "$dstbase".EXE && - $SOCOS -nowarn -target:msil -o "$os_dstbase" -r $assemblies "$@" \ + $SCALAC -nowarn -target:msil -o "$os_dstbase" -r $assemblies "$@" \ "$os_srcbase".scala && case "$UNAME" in CYGWIN* ) @@ -558,7 +558,7 @@ if [ "$TEST_ALL" = "true" ]; then fi; SCALA="${BIN_DIR}scala"; -SOCOS="${BIN_DIR}scalac"; +SCALAC="${BIN_DIR}scalac -encoding iso-8859-1"; SCALAP="${BIN_DIR}scalap"; SCALA_SCALA_ARGS="-Xmx512M $SCALA_SCALA_ARGS"; @@ -575,7 +575,7 @@ fi printf_outline "Source directory is : $SRCDIR\\n"; bin_dir=$BIN_DIR if [ -z "$bin_dir" ]; then - bin_dir=`which "$SOCOS"` && bin_dir=`dirname "$bin_dir"`/; + bin_dir=`which "$SCALAC"` && bin_dir=`dirname "$bin_dir"`/; bin_dir=`test_get_location ${bin_dir}scalac`; fi; printf_outline "Scala binaries in : $bin_dir\\n"; -- cgit v1.2.3