diff options
author | Ichoran <ichoran@gmail.com> | 2014-06-29 10:55:24 -0700 |
---|---|---|
committer | Ichoran <ichoran@gmail.com> | 2014-06-29 10:55:24 -0700 |
commit | 1feda983171fd59297c211e5c466fab8880652ee (patch) | |
tree | 70f173930faacc2733dc38199e3f32c7a6e5c46e | |
parent | fbfce33cb03bc2b41dd0f46fa9f4630036b4f2ca (diff) | |
parent | 4e29e9a229c5a13e8517fe034668aa97ae102eec (diff) | |
download | scala-1feda983171fd59297c211e5c466fab8880652ee.tar.gz scala-1feda983171fd59297c211e5c466fab8880652ee.tar.bz2 scala-1feda983171fd59297c211e5c466fab8880652ee.zip |
Merge pull request #3849 from gourlaysama/wip/t8690
SI-8690 BufferedSource.mkString mistakenly skipped the first char.
-rw-r--r-- | src/library/scala/io/BufferedSource.scala | 2 | ||||
-rw-r--r-- | test/files/run/t8690.check | 2 | ||||
-rw-r--r-- | test/files/run/t8690.scala | 12 |
3 files changed, 15 insertions, 1 deletions
diff --git a/src/library/scala/io/BufferedSource.scala b/src/library/scala/io/BufferedSource.scala index 1c87a1f421..52fa525b24 100644 --- a/src/library/scala/io/BufferedSource.scala +++ b/src/library/scala/io/BufferedSource.scala @@ -93,7 +93,7 @@ class BufferedSource(inputStream: InputStream, bufferSize: Int)(implicit val cod val buf = new Array[Char](bufferSize) var n = 0 while (n != -1) { - n = charReader.read(buf) + n = allReader.read(buf) if (n>0) sb.appendAll(buf, 0, n) } sb.result diff --git a/test/files/run/t8690.check b/test/files/run/t8690.check new file mode 100644 index 0000000000..72f076c4d8 --- /dev/null +++ b/test/files/run/t8690.check @@ -0,0 +1,2 @@ +non-empty iterator +abcdef diff --git a/test/files/run/t8690.scala b/test/files/run/t8690.scala new file mode 100644 index 0000000000..ab8b45b2a7 --- /dev/null +++ b/test/files/run/t8690.scala @@ -0,0 +1,12 @@ +import scala.io.Source +import java.io.ByteArrayInputStream + +object Test extends App { + val txt = "abcdef" + + val in = new ByteArrayInputStream(txt.getBytes()); + val source = Source.fromInputStream(in); + println(source.toString) // forces the BufferedSource to look at the head of the input + + println(source.mkString) // used to return "bcdef" ... +} |