From fc24e7abd48edbe632ebd1449827c5880962e283 Mon Sep 17 00:00:00 2001 From: Gilles Dubochet Date: Tue, 28 Mar 2006 16:00:29 +0000 Subject: Automatic file encoding detection is now Java 1... Automatic file encoding detection is now Java 1.4 compatible. --- src/compiler/scala/tools/nsc/Settings.scala | 32 ++++++++++++++--------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/compiler/scala/tools/nsc/Settings.scala b/src/compiler/scala/tools/nsc/Settings.scala index 78592e7e9f..ab14e2e473 100644 --- a/src/compiler/scala/tools/nsc/Settings.scala +++ b/src/compiler/scala/tools/nsc/Settings.scala @@ -18,11 +18,11 @@ class Settings(error: String => unit) { else null private val classpathDefault = - if (System.getProperty("env.classpath") != null) - alternatePath( - getProperty("env.classpath"), - ".") - else getProperty("java.class.path") + if (System.getProperty("env.classpath") != null) + alternatePath( + getProperty("env.classpath"), + ".") + else getProperty("java.class.path") private val bootclasspathDefault = @@ -57,6 +57,10 @@ class Settings(error: String => unit) { } else null } + private val encodingDefault = + new java.io.OutputStreamWriter( + new java.io.ByteArrayOutputStream()).getEncoding + val doc = BooleanSetting("-doc", "Generate documentation"); val debuginfo = BooleanSetting("-g", "Generate debugging info") val nowarnings = BooleanSetting("-nowarn", "Generate no warnings") @@ -69,8 +73,7 @@ class Settings(error: String => unit) { val bootclasspath = StringSetting ("-bootclasspath", "path", "Override location of bootstrap class files", bootclasspathDefault) 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", - java.nio.charset.Charset.defaultCharset.name) + val encoding = StringSetting ("-encoding", "encoding", "Specify character encoding used by source files", encodingDefault) 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") @@ -148,15 +151,12 @@ class Settings(error: String => unit) { def tryToSet(args: List[String]): List[String] = args match { case n :: rest if (n == name) => if (rest.isEmpty) { - error("missing argument") - List() - } else { - value = rest.head - rest.tail - - - - } + error("missing argument") + List() + } else { + value = rest.head + rest.tail + } case _ => args } -- cgit v1.2.3