pharo
pharo copied to clipboard
ZnUTF8Encoder>>#ensureAtBeginOfCodePointOnStream: sends bitAnd: to nil when setting stream position to end
Bug description
Setting FileReference readStream position to the end causes DNU error for bitAnd: sent to nil.
To Reproduce Evaluate:
| file stream |
file := FileSystem memory / 'test'.
file writeStreamDo: [ :s | s nextPut: $a ].
stream := file readStream.
stream position: file size.
Expected behavior
The stream should be positioned at the end so atEnd returns true.
Version information: Pharo-11.0.0+build.702.sha.a844e9ab79ba34a9f3999f01c81a405408c4dc55 (64 Bit)
Expected development cost
Adding an atEnd check to the ZnUTF8Encoder>>#ensureAtBeginOfCodePointOnStream: method fixes the issue.
[ stream atEnd not and: [ (stream peek bitAnd: 2r11000000) == 2r10000000 ] ] whileTrue: [ stream back ]
This was already fixed in https://github.com/svenvc/zinc/commit/6882f5f06096d56ddee79ff278ecbd09248e7708
this can be closed as duplicate & solved
It appears that the fix from Zinc was never included in Pharo 11-13.
So @svenvc can you let us know what we should do?
take over the fix from @daniels220 I guess. it is only a very small change, an edge case guard.
I do not get it should we use a different version of Zinc? I have no idea what is @daniels220' fix?
@Ducasse the fix is the change in https://github.com/svenvc/zinc/commit/6882f5f06096d56ddee79ff278ecbd09248e7708. But for Pharo I would think the appropriate change would be to ensure the version of Zinc that ships with Pharo is up-to-date with the latest (or latest stable tag or somesuch if that exists) in the Zinc repo, which would include the fix.