[squeak-dev] Caching MultiByteFileStream bug?

Levente Uzonyi leves at elte.hu
Wed Mar 31 02:40:23 UTC 2010


I uploaded two packages to the Inbox which contain the workaround for the 
#atEnd issue.

(Installer repository: 'http://source.squeak.org/inbox')
 	install: 'Files-ul.80.mcz';
 	install: 'Multilingual-ul.118.mcz'

The tests are green, but there may be untested edge cases (probably not, 
but who knows). Please review it.


Levente

On Tue, 30 Mar 2010, Levente Uzonyi wrote:

> On Mon, 29 Mar 2010, Andreas Raab wrote:
>
>> Hi Levente -
>> 
>> Could you check the failure of FileStreamTest>>testNextChunkOutOfBounds? 
>> This looks like it might be a problem with caching file stream behavior. If 
>> it's not (i.e., the infinite recursion is the 'expected' behavior) can we 
>> add something that addresses the issue?
>
> Seems like #primAtEnd: doesn't answer true if position is out of bounds and 
> there are no more bytes to read:
>
> FileStream forceNewFileNamed: 'testFileStreamAtEnd' do: [ :file |
> 	file position: 1000.
> 	self assert: file next isNil.
> 	self assert: file atEnd ].
>
> Read buffering doesn't affect this behavior:
>
> FileStream forceNewFileNamed: 'testFileStreamAtEnd' do: [ :file |
> 	file disableReadBuffering.
>        file position: 1000.
>        self assert: file next isNil.
>        self assert: file atEnd ].
>
> Really:
>
> FileStream forceNewFileNamed: 'testFileStreamAtEnd' do: [ :file |
> 	| fileID buffer1 count |
> 	file disableReadBuffering.
> 	file position: 1000.
> 	fileID := file instVarNamed: #fileID.
> 	buffer1 := String new: 1.
> 	count := file primRead: fileID into: buffer1 startingAt: 1 count: 1.
> 	self assert: count = 0.
> 	self assert: (file primAtEnd: fileID) ].
>
> We can work around this issue with StandardFileStream >> #upTo: and friends 
> (by replacing the old code which uses recursion and is pretty inefficient 
> btw), but I think #atEnd should answer true in this case.
>
>
> Levente
>
>> 
>> Thanks,
>>  - Andreas
>> 
>> 
>
>



More information about the Squeak-dev mailing list