[Pharo-project] WriteStream

Igor Stasenko siguctua at gmail.com
Fri Nov 5 10:30:46 CET 2010


On 5 November 2010 11:20, Benjamin <benjamin.vanryseghem.pharo at gmail.com> wrote:
> Hello everyone,
> I thing, there is a bug in WriteStream, but i'm not sure.
> When I look at this code, I guess aString is not always a String, and
> yesterday, I had a Text send to this method, which raised a DNU error.
> (in blue is what I have change to make it work in my case)
> WriteStream>>nextChunkPut: aString
> "Append the argument, aString, to the receiver, doubling embedded
> terminators."
>
> | i remainder terminator |
> terminator := $!.
> remainder := aString asString.
> [(i := remainder indexOf: terminator) = 0] whileFalse:
> [self nextPutAll: (remainder copyFrom: 1 to: i).
> self nextPut: terminator.  "double imbedded terminators"
> remainder := remainder copyFrom: i+1 to: remainder size].
> self nextPutAll: remainder.
> aString asString includesUnifiedCharacter ifTrue: [
> self nextPut: terminator.
> self nextPutAll: ']lang['.
> aString asString writeLeadingCharRunsOn: self.
> ].
> self nextPut: terminator.
>
>
> Is that a bug ?
>
yes.

I'd say the whole method is a bug. Repeating
aString asString multiple times in code cries out of loud that it
could be anything but not right :)


> Regards,
> Ben



-- 
Best regards,
Igor Stasenko AKA sig.




More information about the Pharo-project mailing list