2 fixes for PositionableStream
Stephen Pope
stp at create.ucsb.edu
Thu Apr 8 16:47:46 UTC 1999
These two methods appear to both have been broken (and thus to have kept ReferenceStreams
from working) in 2.3 with the recent updates.
'From Squeak 2.3 of January 14, 1999 on 07 April 1999 at 3:55:02 am'!
!PositionableStream methodsFor: 'nonhomogeneous accessing' stamp: 'stp 04/07/1999 03:54'!
nextNumber: n
"Answer the next n bytes as a positive Integer or LargePositiveInteger."
| s |
n <= 2
ifTrue: [s := 0.
n timesRepeat: [s := s * 256 + self next].
^s].
s := Integer new: n neg: false.
1 to: n do:
[:i | s digitAt: n + 1 - i put: self next].
"reverse order of significance"
^s normalize! !
!PositionableStream methodsFor: 'nonhomogeneous accessing' stamp: 'stp 04/07/1999 03:54'!
nextString
"Answer a new String read from the receiver. The first byte is the
length of the string, unless it is greater than 192, in which case the
first two bytes encode the length. "
| aString length |
length := self next asciiValue. "first byte."
length >= 192
ifTrue: [length := length - 192 * 256 + self next].
aString := String new: length.
1 to: length do: [:i | aString at: i put: self next asCharacter].
^aString! !
--
stp
Stephen Travis Pope
stp at create.ucsb.edu http://www.create.ucsb.edu/~stp/
More information about the Squeak-dev
mailing list
|