# HG changeset patch # User Claus Gittinger # Date 1484870983 -3600 # Node ID cbd62f582ae7a592930f46f03992d3714e794c01 # Parent 962bd694f813d996a77e1eaa5abd72f1476250b2 #REFACTORING by cg class: CompressionStream comment/format in: #next #nextOrNil changed: #nextByte #nextByteOrNil diff -r 962bd694f813 -r cbd62f582ae7 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|