CompressionStream.st
changeset 4265 cbd62f582ae7
parent 4262 a4efbb47dc1e
child 4311 55d6e8abb73b
--- a/CompressionStream.st	Wed Jan 18 04:58:26 2017 +0000
+++ b/CompressionStream.st	Fri Jan 20 01:09:43 2017 +0100
@@ -454,8 +454,9 @@
 !
 
 next
-    "return the next element, a character or byte (textmode)
-     raise an error, if there are no more elements"
+    "return the next element,
+     as character (text mode) or byte (binary mode). 
+     Possibly raises ReadPastEnd error, if there are no more elements"
 
     |byte|
 
@@ -524,10 +525,12 @@
     mode ~~ #readonly ifTrue:[
         self errorWriteOnly
     ].
-    self fillBuffer ifFalse:[
-        "there is no more element; the stream is at end"
-        ^ self pastEndRead.
-    ].
+    position >= readLimit ifTrue:[
+        self fillBuffer ifFalse:[
+            "there is no more element; the stream is at end"
+            ^ self pastEndRead.
+        ].
+    ].    
     position := position + 1.
     ^ outputBytes at:position.
 !
@@ -539,9 +542,11 @@
     mode ~~ #readonly ifTrue:[
         self errorWriteOnly
     ].
-    self fillBuffer ifFalse:[
-        "there is no more element; the stream is at end"
-        ^ nil.
+    position >= readLimit ifTrue:[
+        self fillBuffer ifFalse:[
+            "there is no more element; the stream is at end"
+            ^ nil.
+        ].
     ].
     position := position + 1.
     ^ outputBytes at:position.
@@ -554,7 +559,8 @@
 !
 
 nextOrNil
-    "return the next element, a character or byte (textmode)
+    "return the next element, 
+     as character (text mode) or byte (binary mode). 
      return nil, if there are no more elements"
 
     |byte|