[squeak-dev] [Cuis] Bug in StandardFileStream upTo:

Levente Uzonyi leves at elte.hu
Sun Feb 14 04:12:00 UTC 2010


On Sat, 13 Feb 2010, keith wrote:

>
> On 13 Feb 2010, at 23:13, Juan Vuletich wrote:
>
>> keith wrote:
>>> Juan,
>>> 
>>> I just found a bug in StandardFileStream upTo:  that seems to be recent.
>>> 
>>> Keith
>>> 
>> Could you post a script that shows the incorrect behavior? I test would be 
>> even better.
>> 
>> Cheers,
>> Juan Vuletich
>
> Ok, it was not as obvious as I thought. peek messes things up.
>
> (FileStream newFileNamed: 'test') nextPutAll: 'hello*world'; close.
> (FileStream concreteStream readOnlyFileNamed: 'test')  position: 0; peek; 
> upTo: $*.
>
> peek appears to set readLimit, and then the following part of upTo: is 
> invoked.
>
> 	collection ifNotNil: [
> 		(position < readLimit and: [
> 			(count := collection indexOf: delim startingAt: 
> position + 1) <= readLimit and: [
> 				count > 0 ] ]) ifTrue: [
> 					^collection copyFrom: position + 1 
> to: (position := position + count) ] ].
>
> this gets it wrong, I think it should be something like,  to: (position := 
> position + count -1) - 1

Seems like Cuis has an older version of the filestream buffering. This bug 
was fixed later in the Trunk, here's the current version:

 	collection ifNotNil: [
 		(position < readLimit and: [
 			(pos := collection indexOf: delim startingAt: position + 1) <= readLimit and: [
 				pos > 0 ] ]) ifTrue: [
 					^collection copyFrom: position + 1 to: (position := pos) - 1 ] ].


Levente

>
> Keith
>
>
>
>



More information about the Squeak-dev mailing list