pharo icon indicating copy to clipboard operation
pharo copied to clipboard

ZnUTF8Encoder>>#ensureAtBeginOfCodePointOnStream: sends bitAnd: to nil when setting stream position to end

Open j-brant opened this issue 2 years ago • 7 comments

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 ]

j-brant avatar Aug 08 '23 19:08 j-brant

This was already fixed in https://github.com/svenvc/zinc/commit/6882f5f06096d56ddee79ff278ecbd09248e7708

svenvc avatar Jan 16 '24 08:01 svenvc

this can be closed as duplicate & solved

svenvc avatar Jan 16 '24 10:01 svenvc

It appears that the fix from Zinc was never included in Pharo 11-13.

j-brant avatar Jul 08 '24 19:07 j-brant

So @svenvc can you let us know what we should do?

Ducasse avatar Jul 09 '24 09:07 Ducasse

take over the fix from @daniels220 I guess. it is only a very small change, an edge case guard.

svenvc avatar Jul 09 '24 09:07 svenvc

I do not get it should we use a different version of Zinc? I have no idea what is @daniels220' fix?

Ducasse avatar Jul 09 '24 09:07 Ducasse

@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.

daniels220 avatar Jul 09 '24 19:07 daniels220