diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/ScriptRunner.scala | 6 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/util/SourceFile.scala | 6 | ||||
-rw-r--r-- | test/files/script/utf8.check | 2 | ||||
-rwxr-xr-x | test/files/script/utf8.scala | 26 |
4 files changed, 37 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/ScriptRunner.scala b/src/compiler/scala/tools/nsc/ScriptRunner.scala index 78a63b2b23..d8ea282122 100644 --- a/src/compiler/scala/tools/nsc/ScriptRunner.scala +++ b/src/compiler/scala/tools/nsc/ScriptRunner.scala @@ -188,10 +188,12 @@ object ScriptRunner { val middle = { val f = new File(filename) + val bsf = getSourceFile(new PlainFile(f)).asInstanceOf[BatchSourceFile] new SourceFileFragment( - getSourceFile(new PlainFile(f)).asInstanceOf[BatchSourceFile], + bsf, headerLength(filename), - f.length.asInstanceOf[Int]) + bsf.length) +// f.length.asInstanceOf[Int]) } val end = new BatchSourceFile("<script trailer>", "\n} }\n".toCharArray) diff --git a/src/compiler/scala/tools/nsc/util/SourceFile.scala b/src/compiler/scala/tools/nsc/util/SourceFile.scala index e32cde800e..b4cf891a44 100644 --- a/src/compiler/scala/tools/nsc/util/SourceFile.scala +++ b/src/compiler/scala/tools/nsc/util/SourceFile.scala @@ -214,7 +214,11 @@ extends BatchSourceFile(name, contents) { underlyingFile, start, stop, - underlyingFile.content.slice(start, stop).toArray) + { assert(start >= 0) + assert(start <= stop) + assert(start <= underlyingFile.length) + assert(stop <= underlyingFile.length) + underlyingFile.content.slice(start, stop).toArray }) def this(underlyingFile: BatchSourceFile, start: Int, stop: Int) = this( diff --git a/test/files/script/utf8.check b/test/files/script/utf8.check new file mode 100644 index 0000000000..29dc0518ff --- /dev/null +++ b/test/files/script/utf8.check @@ -0,0 +1,2 @@ +QWERTY +ЙЦУКЕН diff --git a/test/files/script/utf8.scala b/test/files/script/utf8.scala new file mode 100755 index 0000000000..a47828ad37 --- /dev/null +++ b/test/files/script/utf8.scala @@ -0,0 +1,26 @@ +#!/bin/sh +# fact - A simple Scala script that prints out the factorial of +# the argument specified on the command line. + +cygwin=false; +case "`uname`" in + CYGWIN*) cygwin=true ;; +esac + +SOURCE="$0"; +if $cygwin; then + if [ "$OS" = "Windows_NT" ] && cygpath -m .>/dev/null 2>/dev/null ; +then + format=mixed + else + format=windows + fi + SOURCE=`cygpath --$format "$SOURCE"`; +fi + +exec scala -nocompdaemon "$SOURCE" "$@" +!# + +/*Comment Комментарий*/ +Console.println("QWERTY"); +Console.println("ЙЦУКЕН"); |