[squeak-dev] [Cuis] Bug in StandardFileStream upTo:
juan at jvuletich.org
Mon Feb 15 02:16:38 UTC 2010
Levente Uzonyi wrote:
> On Sat, 13 Feb 2010, keith wrote:
>> On 13 Feb 2010, at 23:13, Juan Vuletich wrote:
>>> keith wrote:
>>>> I just found a bug in StandardFileStream upTo: that seems to be
>>> Could you post a script that shows the incorrect behavior? I test
>>> would be even better.
>>> 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 ] ].
Thanks Levente. Comparing with trunk, I found this, and a few other
methods that I need to load in Cuis. Will have this ready soon.
More information about the Squeak-dev