applied path for #325, update scalac man pages

git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@13775 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
This commit is contained in:
michelou 2008-01-22 17:51:40 +00:00
parent 976f4b7691
commit 1b18b30c5c
5 changed files with 76 additions and 19 deletions

View File

@ -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 =

View File

@ -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)
}

View File

@ -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"
@ -157,9 +161,6 @@ object scalac extends Command {
Definition(
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"),
@ -196,6 +197,9 @@ object scalac extends Command {
Definition(
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 " &
@ -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().")
)
),

View File

@ -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)

View File

@ -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 + "\")")
}
}