diff options
-rw-r--r-- | src/compiler/scala/tools/ant/Scalac.scala | 7 | ||||
-rw-r--r-- | src/library/scala/runtime/RichString.scala | 9 | ||||
-rw-r--r-- | src/manual/scala/man1/scalac.scala | 19 | ||||
-rw-r--r-- | test/files/run/bug0325.check | 15 | ||||
-rw-r--r-- | test/files/run/bug0325.scala | 45 |
5 files changed, 76 insertions, 19 deletions
diff --git a/src/compiler/scala/tools/ant/Scalac.scala b/src/compiler/scala/tools/ant/Scalac.scala index c840f571e5..e69e401455 100644 --- a/src/compiler/scala/tools/ant/Scalac.scala +++ b/src/compiler/scala/tools/ant/Scalac.scala @@ -1,6 +1,6 @@ /* __ *\ ** ________ ___ / / ___ Scala Ant Tasks ** -** / __/ __// _ | / / / _ | (c) 2005-2007, LAMP/EPFL ** +** / __/ __// _ | / / / _ | (c) 2005-2008, LAMP/EPFL ** ** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** @@ -157,8 +157,6 @@ class Scalac extends MatchingTask { * in case of failure. */ private var scalacDebugging: Boolean = false - private var generics: Option[Boolean] = None - /*============================================================================*\ ** Properties setters ** \*============================================================================*/ @@ -353,8 +351,6 @@ class Scalac extends MatchingTask { def setAssemrefs(input: String) { assemrefs = Some(input) } - def setGenerics(input: Boolean) { generics = Some(input) } - /*============================================================================*\ ** Properties getters ** \*============================================================================*/ @@ -555,7 +551,6 @@ class Scalac extends MatchingTask { if (!assemname.isEmpty) settings.assemname.value = assemname.get if (!assemrefs.isEmpty) settings.assemrefs.value = assemrefs.get -// if (!generics.isEmpty) settings.Xgenerics.value = generics.get log("Scalac params = '" + addParams + "'", Project.MSG_DEBUG) var args = diff --git a/src/library/scala/runtime/RichString.scala b/src/library/scala/runtime/RichString.scala index 911a392bcd..322eb8da9c 100644 --- a/src/library/scala/runtime/RichString.scala +++ b/src/library/scala/runtime/RichString.scala @@ -164,17 +164,12 @@ final class RichString(val self: String) extends Proxy with RandomAccessSeq[Char */ def stripMargin: String = stripMargin('|') - private def escape(ch: Char): String = ch match { - case '.' | '$' | '^' | '\\' => "\\" + ch - case _ => "" + ch - } - @throws(classOf[java.util.regex.PatternSyntaxException]) - def split(separator: Char): Array[String] = self.split(escape(separator)) + def split(separator: Char): Array[String] = self.split("\\Q"+separator+"\\E") @throws(classOf[java.util.regex.PatternSyntaxException]) def split(separators: Array[Char]): Array[String] = { - val re = separators.foldLeft("[")(_+_) + "]" + val re = separators.foldLeft("\\Q")(_+_) + "\\E" self.split(re) } diff --git a/src/manual/scala/man1/scalac.scala b/src/manual/scala/man1/scalac.scala index eefbc9d3f2..34d69d2ef4 100644 --- a/src/manual/scala/man1/scalac.scala +++ b/src/manual/scala/man1/scalac.scala @@ -1,11 +1,14 @@ /* NSC -- new Scala compiler - * Copyright 2005-2007 LAMP/EPFL + * Copyright 2005-2008 LAMP/EPFL * @author Stephane Micheloud */ //$Id$ package scala.man1 +/** + * @author Stephane Micheloud + */ object scalac extends Command { import _root_.scala.tools.docutil.ManPage._ @@ -124,7 +127,8 @@ object scalac extends Command { SeqPara( "Specify which backend to use (" & Mono("jvm-1.5,jvm-1.4," & "msil,cldc") & ").", - "The default value is " & Mono("\"jvm-1.4\"") & ".")), + "The default value is " & Mono("\"jvm-1.5\"") & " (was " & + Mono("\"jvm-1.4\"") & " up to Scala version 2.6.1).")), Definition( CmdOption("print"), "Print program with all Scala-specific features removed" @@ -158,9 +162,6 @@ object scalac extends Command { CmdOption("Xcheck-null"), "Emit warning on selection of nullable reference"), Definition( - CmdOption("Xdebug"), - "Output debugging messages."), - Definition( CmdOption("Xdisable-assertions"), "Generate no assertions and assumptions"), Definition( @@ -197,6 +198,9 @@ object scalac extends Command { CmdOption("Xprint-types"), "Print tree types (debugging option)."), Definition( + CmdOption("Xprompt"), + "Display a prompt after each error (debugging option)."), + Definition( CmdOption("Xresident"), "Compiler stays resident, files to compile are read from standard " & "input."), @@ -211,7 +215,10 @@ object scalac extends Command { "Print a synopsis of compiler phases."), Definition( CmdOption("Xsource-reader", Argument("classname")), - "Specify a custom method for reading source files.") + "Specify a custom method for reading source files."), + Definition( + CmdOption("Xscript", Argument("object")), + "Compile as a script, wrapping the code into object.main().") ) ), diff --git a/test/files/run/bug0325.check b/test/files/run/bug0325.check new file mode 100644 index 0000000000..71d1f3feb5 --- /dev/null +++ b/test/files/run/bug0325.check @@ -0,0 +1,15 @@ + + +RichString split("x]") returned List(a]b) when expecting List(a, b) +RichString split("&&") returned List(a&b) when expecting List(a, b) +RichString split("\x") returned List(a\b) when expecting List(a, b) +RichString split("[x") returned List(a[b) when expecting List(a, b) +RichString split("^x") returned List(a^b) when expecting List(a, b) +RichString split("x-z") returned List(a-b) when expecting List(a, b) + +RS split("x]") returned List(a]b) when expecting List(a, b) +RS split("&&") returned List(a&b) when expecting List(a, b) +RS split("\x") returned List(a\b) when expecting List(a, b) +RS split("[x") returned List(a[b) when expecting List(a, b) +RS split("^x") returned List(a^b) when expecting List(a, b) +RS split("x-z") returned List(a-b) when expecting List(a, b) diff --git a/test/files/run/bug0325.scala b/test/files/run/bug0325.scala new file mode 100644 index 0000000000..18193ff960 --- /dev/null +++ b/test/files/run/bug0325.scala @@ -0,0 +1,45 @@ +case class RS(self: String) { + def split(separator: Char): Array[String] = self.split("\\Q"+separator+"\\E") + + def split(separators: Array[Char]): Array[String] = { + val re = separators.foldLeft("[\\Q")(_+_) + "\\E]" + self.split(re) + } +} + +object Test { + def expect = List("a","b") + def test(f: => Array[String], which: String) { + try { + val ret = f.toList + if (ret != expect) { + println(which + " returned " + ret + " when expecting " + expect) + } + } catch { + case e@_ => println(which + " failed with " + e.getClass) + } + } + + def main(args: Array[String]) { + val badChars = "?*{+([\\^.$" + + for (c <- badChars) + test(("a"+c+"b").split(c),"RichString split('"+ c + "')") + println + + for (c <- badChars) + test(RS("a"+c+"b").split(c),"RS split('"+ c + "')") + println + + val badCases = List( + ']' -> "x]", '&' -> "&&",'\\' -> "\\x", '[' -> "[x", + '^' -> "^x", '-' -> "x-z" + ) + for ((c,str) <- badCases) + test(("a"+c+"b").split(str.toArray),"RichString split(\""+ str + "\")") + println + + for ((c,str) <- badCases) + test(RS("a"+c+"b").split(str.toArray),"RS split(\""+ str + "\")") + } +} |