From ca6b2dcd8104b2bebc6edcaf76618d7bae07290b Mon Sep 17 00:00:00 2001 From: Lex Spoon Date: Wed, 30 May 2007 10:58:09 +0000 Subject: Settings.tryToSet consistently returns its inpu... Settings.tryToSet consistently returns its input arguments if there is an error. That way, the command-line parser can consitently recognize that there is an erroneous option and abort. --- src/compiler/scala/tools/nsc/GenericRunnerCommand.scala | 2 +- src/compiler/scala/tools/nsc/Settings.scala | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/compiler/scala/tools/nsc/GenericRunnerCommand.scala b/src/compiler/scala/tools/nsc/GenericRunnerCommand.scala index 26742f5a88..3c08c603af 100644 --- a/src/compiler/scala/tools/nsc/GenericRunnerCommand.scala +++ b/src/compiler/scala/tools/nsc/GenericRunnerCommand.scala @@ -33,7 +33,7 @@ class GenericRunnerCommand(allargs: List[String], error: String => Unit) { if (args eq args0) args = setting.tryToSet(args) if (args eq args0) { - error("unknown option: '" + args.head + "'") + error("bad option: '" + args.head + "'") ok = false } } diff --git a/src/compiler/scala/tools/nsc/Settings.scala b/src/compiler/scala/tools/nsc/Settings.scala index 87d0defa00..79b6a6c140 100644 --- a/src/compiler/scala/tools/nsc/Settings.scala +++ b/src/compiler/scala/tools/nsc/Settings.scala @@ -206,7 +206,7 @@ class Settings(error: String => Unit) { /** If first arg defines this setting, consume it as well as all following * args needed to define the setting. If this can be done without * error, set value field and return suffix of args else - * issue error message and return empty. + * issue error message and return the arguments unchanged. * If first arg does not define this setting return args unchanged. */ def tryToSet(args: List[String]): List[String] @@ -267,7 +267,7 @@ class Settings(error: String => Unit) { case n :: rest if (name == n || abbreviation == n) => if (rest.isEmpty) { error("missing argument") - List() + args } else { value = rest.head rest.tail @@ -374,7 +374,7 @@ class Settings(error: String => Unit) { val phase = n.substring(name.length() + 1) if (phase == "") { error("missing phase") - List() + args } else { value = value ::: List(phase) rest -- cgit v1.2.3