ReadStream.st
branchjv
changeset 19948 be658f466bca
parent 19567 33f60845c4bc
parent 19924 2b355de2451e
child 20134 cab81d17f2d9
--- a/ReadStream.st	Mon Jun 06 10:37:21 2016 +0100
+++ b/ReadStream.st	Mon Jun 06 10:56:12 2016 +0100
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "
  COPYRIGHT (c) 1988 by Claus Gittinger
 	      All Rights Reserved
@@ -73,8 +75,8 @@
 
 next: n into: aCollection startingAt: startIndex
     "Read n objects into the given collection.
-    Return aCollection or a partial copy if less than
-    n elements have been read."
+     Return aCollection or a partial copy if less than
+     n elements have been read."
 
     | max |
 
@@ -259,20 +261,22 @@
 
     |answer|
 
-    self contentsSpecies == collection class ifTrue:[
-	((position + count) > readLimit) ifFalse:[
-	    answer := collection copyFrom:position+1 to:position+count.
-	    position := position+count.
-	    ^ answer
-	].
+    collection notNil ifTrue:[
+        self contentsSpecies == collection class ifTrue:[
+            ((position + count) > readLimit) ifFalse:[
+                answer := collection copyFrom:position+1 to:position+count.
+                position := position+count.
+                ^ answer
+            ].
+        ].
     ].
     ^ super next:count
 
     "
      #[1 2 3 4 5 6 7 8 9] readStream
-	next;
-	next:5;
-	next.
+        next;
+        next:5;
+        next.
     "
 !