Mantis Bugtracker
  

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0007167 [Squeak] System major always 08-29-08 11:46 09-19-09 20:55
Reporter norbertf View Status public  
Assigned To
Priority normal Resolution open  
Status feedback   Product Version 3.10
Summary 0007167: ReadWriteStream opened with "on: aCollection" always has readLimit 0
Description Example:
"(ReadWriteStream on: 'abc') next"
returns nil

Encountered this when trying in vain:
"Form fromBinaryStream: (RWBinaryOrTextStream on: file contents)"

The reason is that ReadWriteStream is a subclass of WriteStream which does "readLimit := 0" in its WriteStream>on: method.

my fix is:
-----------
'From Squeak3.10-basic of 26 May 2008 [latest update: 0007160] on 29 August 2008 at 1:27:05 pm'!

!ReadWriteStream methodsFor: 'private' stamp: 'nf 8/29/2008 13:26'!
on: aCollection
'fixing the bug that a ReadWriteStream had the readLimit set to 0 from the WriteStream>on: method'
    super on: aCollection.
    readLimit := aCollection size! !
-----------
After fixing this I saw immediately one side effect:
A real time clock in a seaside interface showed extraneous garbage characters at the end. I suspect this is another bug.
Additional Information A cursory glance at references to ReadWriteStream seems to indicate that most uses are for writing rather than reading which would explain why this bug was not noticed before.
Attached Files

- Relationships

- Notes
(0012537 - 161 - 205 - 205 - 205 - 205 - 205)
norbertf
08-29-08 12:32

Found a better fix for my problem:
(ReadWriteStream with: 'abc') reset next
works
It seems like "on:" is for writing
and "with:" is for reading and writing.
 
(0012711 - 29 - 29 - 29 - 29 - 29 - 29)
Keith_Hodges
10-01-08 01:35

Do others agree with Norbert?
 
(0013007 - 140 - 164 - 164 - 164 - 164 - 164)
nicolas cellier
03-05-09 19:35

Good questions could be
What does ANSI says ?
What do other dialects do ?
And last, is it worth changing ?
(how much code would break ?)
 
(0013313 - 390 - 426 - 426 - 426 - 426 - 426)
nicolas cellier
09-19-09 20:55

Note: VW and Dolphin behave same as Squeak...
VW (ReadWriteStream on: 'abc') next -> nil
Dolphin (ReadWriteStream on: 'abc') next -> EndOfStreamError

But using #with: leads to same results as using #on: and is thus different than Squeak.
If I understand correctly, VW and Dolphin #with: are ANSI compliant, Squeak is not: ANSI says the stream initially has no future value (for read).
 

- Issue History
Date Modified Username Field Change
08-29-08 11:46 norbertf New Issue
08-29-08 12:32 norbertf Note Added: 0012537
08-29-08 12:39 norbertf Issue Monitored: norbertf
10-01-08 01:35 Keith_Hodges Note Added: 0012711
01-10-09 02:39 Keith_Hodges Status new => feedback
03-05-09 19:35 nicolas cellier Note Added: 0013007
09-19-09 20:55 nicolas cellier Note Added: 0013313


Mantis 1.0.8[^]
Copyright © 2000 - 2007 Mantis Group
49 total queries executed.
36 unique queries executed.
Powered by Mantis Bugtracker