#REFACTORING by cg
authorClaus Gittinger <cg@exept.de>
Fri, 20 Jan 2017 01:09:43 +0100
changeset 4265 cbd62f582ae7
parent 4264 962bd694f813
child 4266 c04e8a065da5
child 4289 117a575c5b99
#REFACTORING by cg class: CompressionStream comment/format in: #next #nextOrNil changed: #nextByte #nextByteOrNil
CompressionStream.st
--- 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|