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

Juan Vuletich juan at jvuletich.org
Mon Feb 15 02:13:09 UTC 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
>
> Keith

Oh! Thanks for the report! I'll update the FileStream code to latest in 
trunk ASAP.

Cheers,
Juan Vuletich



More information about the Squeak-dev mailing list